Weapon#fire()

fire(from, x, y) → {Phaser.Bullet}

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 false. It will also return false if not enough time has expired since the last time
the Weapon was fired, as defined in the Weapon.fireRate property.

Otherwise the first available bullet is selected and launched.

The arguments are all optional, but allow you to control both where the bullet is launched from, and aimed at.

If you don't provide any of the arguments then it uses those set via properties such as Weapon.trackedSprite,
Weapon.bulletAngle and so on.

When the bullet is launched it has its texture and frame updated, as required. The velocity of the bullet is
calculated based on Weapon properties like bulletSpeed.

Parameters
Name Type Argument Description
from Phaser.Sprite | Phaser.Point | Object <optional>

Optionally fires the bullet from the x and y properties of this object. If set this overrides Weapon.trackedSprite or trackedPointer. Pass null to ignore it.

x number <optional>

The x coordinate, in world space, to fire the bullet towards. If left as undefined the bullet direction is based on its angle.

y number <optional>

The y coordinate, in world space, to fire the bullet towards. If left as undefined the bullet direction is based on its angle.

Returns

The fired bullet if successful, null otherwise.

Source code: plugins/weapon/WeaponPlugin.js (Line 691)
doc_phaser
2017-02-14 11:19:50
Comments
Leave a Comment

Please login to continue.