Create Timer, Countdown
Select GUI
Select GUI to show countdown, timer.
Select Timer, Countdown GUI
You can adjust gui properties here
Code
If you want to start the timer, you can use setInterval()
.
timer
let count = 0;
const countboard = GUI.getObject("startBD");
function Start() {
const startCount = setInterval(() => {
count++;
countboard.setText(count, true);
}, 1000);
}
If you want to stop the timer, you can use clearInterval()
.
timer
let count = 0;
const countboard = GUI.getObject("startBD");
function Start() {
const startCount = setInterval(() => {
count++;
countboard.setText(count, true);
if (count >= 10) {
clearInterval(startCount);
}
}, 1000);
}
Here you can use REDBRICK timer to achive similar results.
timer
let count = 0;
const countboard = GUI.getObject("startBD")
const timer = new REDBRICK.Timer();
function Start() {
countboard.setText(count, true);
timer.start();
}
function Update(dt){
count = Math.floor( timer.getTime() );
countboard.setText( count ,true);
}
You can find information about โREDBRICK.Timerโ here.
timer
let count = 0;
const countboard = GUI.getObject("startBD")
const timer = new REDBRICK.Timer();
function Start() {
countboard.setText(count, true);
timer.start();
}
function Update(dt){
count = Math.floor( timer.getTime() );
if (count >= 10){
timer.pause();
}
countboard.setText( count ,true);
}
Result