Jump to content

Code not understood


arun
 Share

Recommended Posts

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);

}
 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...