-
Notifications
You must be signed in to change notification settings - Fork 0
Timer
Gentilhomme edited this page Jul 26, 2016
·
3 revisions
Timers are simple clock that increments by 1 each frame. They help you to execute triggers at specific time or creating ... clock ^^.
class gameBehavior extends Sup.Behavior {
private timer : United.Timer;
awake() {
this.timer = new United.Timer();
}
update() {
if(this.timer.walk(U.FPS * 2)) { // FPS * 2 equal 120 frames
// Execute this block every two seconds
}
if(this.timer.elapsed(U.FPS * 160)) {
// Execute one time this block when 160 seconds have elapsed.
this.timer.reset(); // The end of the round ? Restart the game :D
// RestartGame();
}
}
}
constructor(autoStart?: boolean = true)
start() : void
stop() : void
reset() : void
getTick(interval: number) : number
walk(interval: number) : boolean
elapsed(elapsedFrame: number) : boolean
Timer are updated by the Engine.
update() : void
Contributor :
- Fraxken
- Purexo