vmars316 Posted January 23, 2016 Share Posted January 23, 2016 function fireBullet () { if (game.time.now > bulletTime) { bullet = bullets.getFirstExists(false); if (bullet) { bullet.reset(throwerSprite.body.x + 16, throwerSprite.body.y + 16); bullet.lifespan = 2000; bullet.body.velocity.y = -300; bullet.body.acceleration.y = -300; //prevent init tick error setTimeout(function(){ timer.start() }, 250) bulletTime = game.time.now + 50; } } } Hello & Thanks , I am getting muti bullet fires on single isDown . How can I prevent that . I have search thru all *.js examples for things like time, wait, delay, cursors.up.isDown, cursors.up.isPush, setTimeout, but no help . Pls, what will work ? Thanks Btw: Is there a way to search all of API in one search ? As a noob its hard to know exactly what to search for . Link to comment Share on other sites More sharing options...
megmut Posted January 25, 2016 Share Posted January 25, 2016 function fire() { if (game.time.now > nextFire && bullets.countDead() > 0) { nextFire = game.time.now + fireRate; var bullet = bullets.getFirstDead(); bullet.reset(sprite.x - 8, sprite.y - 8); game.physics.arcade.moveToPointer(bullet, 300); } } This is dragged from the one of the examples. I use it in my code, using scoped variables where the 300 is the speed of the bullet, and the nextFire is the time until the next fire aka (delay). Hope this helps. Please find the example here: http://phaser.io/examples/v2/arcade-physics/shoot-the-pointer Link to comment Share on other sites More sharing options...
vmars316 Posted January 25, 2016 Author Share Posted January 25, 2016 megmut Thank you very much ! Link to comment Share on other sites More sharing options...
Recommended Posts