dandorf Posted October 6, 2014 Share Posted October 6, 2014 For example, in a shooting game. That when you throw a shot, you may have to wait a while to be able to pull another shot. Any ideas? Link to comment Share on other sites More sharing options...
nkholski Posted October 6, 2014 Share Posted October 6, 2014 function shoot(){ if(nextShot>game.time.now){return;} // too early /* make shot */ nextShot = game.time.now + 1000; // wait at least 1 second (1000ms) to next shot } Link to comment Share on other sites More sharing options...
dandorf Posted October 6, 2014 Author Share Posted October 6, 2014 Yes, that works perfectly, thanks. And for example, to do something to stop the game in general? The bullet for a second or two stops, for instance. There any instructions for this? Link to comment Share on other sites More sharing options...
spencerTL Posted October 6, 2014 Share Posted October 6, 2014 Do you mean pause the whole game?You can set: game.paused = true;Here's the example to pause and then unpause:http://examples.phaser.io/_site/view_full.html?d=misc&f=pause+menu.js&t=pause%20menuThis example currently looks a bit funky on iPad due to a webGL issue so check it out on a PC. Link to comment Share on other sites More sharing options...
Hulsen Posted October 25, 2017 Share Posted October 25, 2017 On 6 de outubro de 2014 at 4:10 PM, nkholski said: function shoot(){ if(nextShot>game.time.now){return;} // too early /* make shot */ nextShot = game.time.now + 1000; // wait at least 1 second (1000ms) to next shot } There is also the this.game.time.events.add(TIME, function () { //DO STUFF}, self); But I really liked this way. Link to comment Share on other sites More sharing options...
DarkMoon_Lander Posted July 12, 2020 Share Posted July 12, 2020 On 10/6/2014 at 3:10 PM, nkholski said: function shoot(){ if(nextShot>game.time.now){return;} // too early /* make shot */ nextShot = game.time.now + 1000; // wait at least 1 second (1000ms) to next shot } This also works with Phaser 3 Link to comment Share on other sites More sharing options...
Recommended Posts