addBulletAnimation(name, frames, frameRate, loop, useNumericIndex) → {Phaser.Weapon}
Adds a new animation under the given key. Optionally set the frames, frame rate and loop.
The arguments are all the same as for Animation.add
, and work in the same way.
Weapon.bulletAnimation
will be set to this animation after it's created. From that point on, all
bullets fired will play using this animation. You can swap between animations by calling this method
several times, and then just changing the Weapon.bulletAnimation
property to the name of the animation
you wish to play for the next launched bullet.
If you wish to stop using animations at all, set Weapon.bulletAnimation
to '' (an empty string).
Parameters
Name | Type | Argument | Default | Description |
---|---|---|---|---|
name | string | The unique (within the Weapon instance) name for the animation, i.e. "fire", "blast". | ||
frames | Array | <optional> | null | An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used. |
frameRate | number | <optional> | 60 | The speed at which the animation should play. The speed is given in frames per second. |
loop | boolean | <optional> | false | Whether or not the animation is looped or just plays once. |
useNumericIndex | boolean | <optional> | true | Are the given frames using numeric indexes (default) or strings? |
Returns
The Weapon Plugin.
- Source code: plugins/weapon/WeaponPlugin.js (Line 1048)
Please login to continue.