Skell Posted July 17, 2014 Share Posted July 17, 2014 Нow to dynamically change the property delay in object Phaser.Timer?this.timer = this.game.time.create(false);this.timer.loop(1000, this.onTimer, this);this.timer.start();....this.timer.stop();this.timer.delay = 4000; // Access to the property delay is notthis.timer.start();Now it is necessary to create Timer, to set a different value property delay... Link to comment Share on other sites More sharing options...
lewster32 Posted July 17, 2014 Share Posted July 17, 2014 Delay is a property of the TimerEvent, not the Timer:// create a new looping TimerEvent on the default game timer and return itthis.loopTimer = game.time.events.loop(1000, this.onTimer, this);// we can now modify its delaythis.loopTimer.delay = 500;The Timer object should be thought of as a manager for TimerEvents, which are the actual objects you use to do the work. Link to comment Share on other sites More sharing options...
Skell Posted July 17, 2014 Author Share Posted July 17, 2014 Thank you. How to destroy TimerEvent? this.loopTimer.timer.remove(this.loopTimer); this.loopTimer = null;orthis.loopTimer.pendingDelete = true; this.loopTimer = null; Link to comment Share on other sites More sharing options...
lewster32 Posted July 17, 2014 Share Posted July 17, 2014 game.time.events.remove(this.loopTimer);As game.time.events is an instance of Timer, or...this.loopTimer.timer.remove(this.loopTimer);Again, the Timer manages the events - and in the second instance, the TimerEvent itself keeps a reference to its managing Timer, so you can call remove from that reference. Link to comment Share on other sites More sharing options...
Recommended Posts