ThatGirlDee Posted September 20, 2015 Share Posted September 20, 2015 I'm trying to set a timer to remove the onDown callback if the onDown input is enabled for a certain amount of seconds. At this stage I have a timer in the update function which should just print a word, but the timer never fires and the word is never printed. I feel like I have missed something simple but any help would be much appreciated. my timer looks like thisthis.game.time.events.loop(delay, this.touchOff, this); the function touchOff simply prints "TOUCH OFF" at the moment. Link to comment Share on other sites More sharing options...
MichaelD Posted September 20, 2015 Share Posted September 20, 2015 Try it like thisvar timer = this.game.time.events.loop(delay, this.touchOff, this);timer.start(); Link to comment Share on other sites More sharing options...
rich Posted September 20, 2015 Share Posted September 20, 2015 Your code is fine. What does 'delay' contain? Try replacing it with Phaser.Timer.SECOND and see what happens. The timer doesn't need starting because you're using the global Phaser Timer, so it must be something else going on. Either it never got a chance to start, or touchOff couldn't be accessed, or delay doesn't hold a ms value. Link to comment Share on other sites More sharing options...
ThatGirlDee Posted September 20, 2015 Author Share Posted September 20, 2015 Thanks Rich! when I console logged delay it logged Infinity, after changing this it worked. Link to comment Share on other sites More sharing options...
Recommended Posts