Jump to content

Timer in Phaser 2


jwfurness
 Share

Recommended Posts

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

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

  • 3 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...