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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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