metalNumb 4 Report post Posted November 21, 2014 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. Quote Share this post Link to post Share on other sites
rvizcaino 6 Report post Posted November 21, 2014 Hi, what I do is this: //Define timerthis.myTimer = this.game.time.create(false);//Define add, loop or repeat and callbackthis.myTimer.loop(3000, this.myCallback, this);//Start timerthis.myTimer.start();//Pause the timerthis.myTimer.pause(); 2 metalNumb and sifon reacted to this Quote Share this post Link to post Share on other sites
metalNumb 4 Report post Posted November 22, 2014 It worked like a charm,thank you SO MUCH ! Quote Share this post Link to post Share on other sites