jwfurness Posted March 23, 2014 Share Posted March 23, 2014 Hello all, I used the timer successfully in my last game using version 1.16. Decided to try 2.0 on my next game, and it seems something has changed. The timer doesn't seem to be firing every 2 seconds, as specified in the create function. Instead, it's calling createSoldier function every frame. Appreciate any help, thanks. http://www.gardenvideogames.com/games/siege-of-jerusalem/ create: function () { // Start arcade physics engine this.physics.startSystem(Phaser.Physics.ARCADE); this.gameBg = this.add.sprite(0, 0, 'gameBg'); this.enemySoldiers = this.game.add.group(); // Enemy create timers this.timer1 = this.game.time.create(false); this.timer1.loop(2000, this.createSoldier, this); this.timer1.start(); }, update: function () { }, createSoldier: function () { // Create soldier inside soldier group this.enemySoldier = this.enemySoldiers.create(Math.random() * 768, 0, 'enemySoldier'); this.physics.enable(this.enemySoldier, Phaser.Physics.ARCADE); // Speed at which mannas drop this.enemySoldier.body.velocity.y = 20; } Link to comment Share on other sites More sharing options...
StrykerKKD Posted March 23, 2014 Share Posted March 23, 2014 Try without the start() function.I think in phaser 2.0 the loop automatically starts. I use the loop this way:event = game.time.events.loop(time,function,this); Link to comment Share on other sites More sharing options...
rich Posted March 24, 2014 Share Posted March 24, 2014 jwfurness - actually you found a bug, sorry! This is now fixed in the 2.0.1 version (in the dev branch currently). In the meantime you can fix it by putting timer.start BEFORE you add any events to the timer. Then it will work as expected. Or you can upgrade to 2.0.1-dev. We should go to master at some point today (24th March). Link to comment Share on other sites More sharing options...
jwfurness Posted March 24, 2014 Author Share Posted March 24, 2014 Great. I'll hold off until 2.0.1 is live. Thanks! Link to comment Share on other sites More sharing options...
rich Posted March 24, 2014 Share Posted March 24, 2014 It is Link to comment Share on other sites More sharing options...
MichaelD Posted July 13, 2014 Share Posted July 13, 2014 In 2.0.6 trying to create a loop like this: game.time.events.loop(1000, function(){window.console.log("1");}, this, []);But nothing runs... any ideas? Link to comment Share on other sites More sharing options...
Recommended Posts