royibernthal Posted May 6, 2014 Share Posted May 6, 2014 I'm trying to add a new timer when my state is created (the code is reached for sure), and nothing happens: this.bla = function(){alert("Finished");} var tr = new Phaser.Timer(game, false); tr.add(this.bla, 100, this); What am I doing wrong? Also it'd be great if anyone could explain to me what's callback context and what might be its uses. Link to comment Share on other sites More sharing options...
Manifest Posted May 7, 2014 Share Posted May 7, 2014 First off, my understanding of callbackContext is basically "when I call this.something in the callback, this points to the callbackContext." Secondly, I don't think you're calling timer.start(). Link to comment Share on other sites More sharing options...
royibernthal Posted May 7, 2014 Author Share Posted May 7, 2014 callbackContext - I understand, thanks. sorry I didn't copy that line, I am calling tr.start() right after the tr.add() line. Link to comment Share on other sites More sharing options...
royibernthal Posted May 7, 2014 Author Share Posted May 7, 2014 bump Link to comment Share on other sites More sharing options...
Manifest Posted May 7, 2014 Share Posted May 7, 2014 Instead of doing a timer that way, try:game.time.events.add(5000, this.bla, this);I have that code in one of my Typescript projects and it works for me - the syntax should be the same.You don't need to call start() on it that way either. Link to comment Share on other sites More sharing options...
royibernthal Posted May 8, 2014 Author Share Posted May 8, 2014 Yeah I actually already stumbled upon it in my search and it indeed works, thanks. Would I need to remove it with game.time.events.remove or something similar or is it removed automatically? Link to comment Share on other sites More sharing options...
Recommended Posts