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 | number | <optional> | The x coordinate, in world space, to fire the bullet towards. If left as |
y | number | <optional> | The y coordinate, in world space, to fire the bullet towards. If left as |
Returns
The fired bullet if successful, null otherwise.
- Source code: plugins/weapon/WeaponPlugin.js (Line 691)
Please login to continue.