Jump to content

weapon.fire() return null


Kirino
 Share

Recommended Posts

Hi all,

I've a problem with weapon.fire(), he return null.

here, a part of my code (where i use weapon)

Quote

var weapon;

preload(){

  game.load.image('bullet','asset/weapon/bullet.png');
  game.load.spritesheet("dude","asset/sprite/dude.png",32,48);

}

create(){

  weapon = game.add.weapon(30,'bullet');

  weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS;

  weapon.bulletSpeed = 600;

  weapon.fireRate = 100;

  player = this.add.sprite(32, game.world.height - 150, 'dude');

  weapon.trackSprite(player,0,0,true);

}

update(){

if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
        {
            console.log(weapon.fire());
        }
}

 

 

Link to comment
Share on other sites

https://photonstorm.github.io/phaser-ce/Phaser.Weapon.html#fire

Quote

Attempts to fire a single Bullet. If there are no more bullets available in the pool, and the pool cannot be extended, then this method returns null. It will also return null if not enough time has expired since the last time the Weapon was fired, as defined in the Weapon.fireRate property.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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