Jump to content

Can't pause/resume spawning timers.


metalNumb
 Share

Recommended Posts

Hey everyone !

 

So i have a simple logic that i want to implement in my game,

i have these two timers in the create function that are supposed to spawnEnemies or spawn energyCapsules.

enemyTimer = this.time.events.loop(Phaser.Timer.SECOND * 0.5, spawnEnemy,this) ;energyTimer = this.time.events.loop(Phaser.Timer.SECOND * 0.5, spawnEnergyCapsule,this) ;

So if both are enabled at the same time (Which is not what i intend to make), they work just fine.

what i want to do is, i have a state variable, a flag if you want, named it energyFull, that when the player collects enough capsules, enemies will start being spawned, and energyCapsules will stop being spawned. 

 

So i need the following...

1- The game starts, the energyTimer starts, while enemyTimer stopped. 

2- When enough energyCapsules are collected,

energyFull=true,

then pause energyTimer and start enemyTimer to start spawning enemies. 

3- Using another timer that counts for 10 seconds for example, after which all energy is lost, the energyFull = false and the reverse happens ( no enemies, more capsules ). 

 

I tried using enemyTimer.pause() or destroy() as i have seen in another forum topic, specifically this one...

 

http://www.html5gamedevs.com/topic/7202-pausing-and-resuming-timer/

 

but for me they don't work at all, Help please. 

Thank you. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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