dandorf Posted October 6, 2014 Report 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? Quote Link to comment Share on other sites More sharing options...
nkholski Posted October 6, 2014 Report 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 } Quote Link to comment Share on other sites More sharing options...
dandorf Posted October 6, 2014 Author Report 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? Quote Link to comment Share on other sites More sharing options...
spencerTL Posted October 6, 2014 Report 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. Quote Link to comment Share on other sites More sharing options...
Hulsen Posted October 25, 2017 Report 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. Quote Link to comment Share on other sites More sharing options...
DarkMoon_Lander Posted July 12, 2020 Report 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.