arun 0 Report post Posted May 6, 2018 Hi friends, I don't understand the following code . please help me this.bullets = []; this.nextShotAt = 0; this.shotDelay = 100; fire: function() { if (this.nextShotAt > this.time.now) { return; } this.nextShotAt = this.time.now + this.shotDelay; var bullet = this.add.sprite(this.player.x, this.player.y - 20, 'bullet'); bullet.anchor.setTo(0.5, 0.5) ; this.physics.enable(bullet, Phaser.Physics.ARCADE); bullet.body.velocity.y = -500; this.bullets.push(bullet); } Share this post Link to post Share on other sites
PsichiX 32 Report post Posted May 7, 2018 this code ensures that there will be 100 ms delay between fire shots. it also creates a sprite and sets its body velocity so bullet will use physics for movement. the stupid part there is that this code does not give a f*** about destroying bullets, so i hope the full source that you use have this. thanks for me for being helpful. 1 b10b reacted to this Share this post Link to post Share on other sites