Jump to content

Physics time and game.time.events.add


JackAttack
 Share

Recommended Posts

I'm trying to create a fast-forward mode in a tower defence game. The physics time can be sped up threefold simply using the following:

game.time.slowMotion = 1/3;
game.time.desiredFps = 20;

The problem is the game has many timed events, which use game time, not the physics time that slow-motion affects, set up using code like the following:

game.time.events.add(
	Phaser.Timer.SECOND * seconds,
	this.spawnAttacker,
	this,
	className
).autoDestroy = true

Where seconds is some numeric value.

So the physics time speeds up 3x just fine, however in the above example, the spawnAttacker function still only occurs every real-time X seconds. I want it to be modified by game.time.slowMotion.

I know I could just do Phaser.Timed.SECOND * seconds * game.time.slowMotion; however when fast-forward mode is toggled on/off, all the existing scheduled events will then be incorrect.

Does anyone know if it is possible to schedule events like this in the physics time which game.time.slowMotion will affect?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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