| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
textures |
Texture[] | AnimatedSprite.FrameObject[] |
An array of Texture or frame objects that make up the animation. |
||
autoUpdate |
boolean |
<optional> |
true |
Whether to use Ticker.shared to auto update animation time. |
Example
import { AnimatedSprite, Assets } from 'pixi.js';
const sheet = await Assets.load('assets/spritesheet.json');
animatedSprite = new AnimatedSprite(sheet.animations['image_sequence']);
Extends
- Sprite
Interface Definitions
Members
The speed that the AnimatedSprite will play at. Higher is faster, lower is slower.
- Default Value:
- 1
Whether to use Ticker.shared to auto update animation time.
The AnimatedSprite's current frame index.
Whether or not the animate sprite repeats after playing.
- Default Value:
- true
User-assigned function to call when an AnimatedSprite finishes playing.
Example
animation.onComplete = () => {
// Finished!
};
User-assigned function to call when an AnimatedSprite changes which texture is being rendered.
Example
animation.onFrameChange = () => {
// Updated!
};
User-assigned function to call when loop is true, and an AnimatedSprite is played and
loops around to start again.
Example
animation.onLoop = () => {
// Looped!
};
Indicates if the AnimatedSprite is currently playing.
textures Texture[] | AnimatedSprite.FrameObject[]
The array of textures used for this AnimatedSprite.
The total number of frames in the AnimatedSprite. This is the same as number of textures assigned to the AnimatedSprite.
- Default Value:
- 0
Update anchor to Texture's defaultAnchor when frame changes.
Useful with sprite sheet animations created with tools. Changing anchor for each frame allows to pin sprite origin to certain moving feature of the frame (e.g. left foot).
Note: Enabling this will override any previously set anchor on each frame change.
- Default Value:
- false
Methods
AnimatedSprite.fromFrames (frames) AnimatedSprite static
A short hand way of creating an AnimatedSprite from an array of frame ids.
| Name | Type | Description |
|---|---|---|
frames |
string[] |
The array of frames ids the AnimatedSprite will use as its texture frames. |
Returns:
| Type | Description |
|---|---|
| AnimatedSprite |
|
AnimatedSprite.fromImages (images) AnimatedSprite static
A short hand way of creating an AnimatedSprite from an array of image ids.
| Name | Type | Description |
|---|---|---|
images |
string[] |
The array of image urls the AnimatedSprite will use as its texture frames. |
Returns:
| Type | Description |
|---|---|
| AnimatedSprite | The new animate sprite with the specified images as frames. |
Stops the AnimatedSprite and destroys it.
Goes to a specific frame and begins playing the AnimatedSprite.
| Name | Type | Description |
|---|---|---|
frameNumber |
number |
Frame index to start at. |
Stops the AnimatedSprite and goes to a specific frame.
| Name | Type | Description |
|---|---|---|
frameNumber |
number |
Frame index to stop at. |
Plays the AnimatedSprite.
Stops the AnimatedSprite.
Updates the object transform for rendering.
| Name | Type | Description |
|---|---|---|
ticker |
Ticker |
{Ticker} - current delta time |
ticker.deltaTime |
the delta time since the last tick |