Sign in to follow this  

Code not understood

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 >

{ return; }
this.nextShotAt = + 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

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.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.