Constructor
new SpriteAnimator(clips)
Create an animator from its clips, showing the first one
Parameters:
| Name | Type | Description |
|---|---|---|
clips | Object.<string, SpriteAnimation> | The clips by name |
- Source
Example
const hero = new SpriteAnimator({
idle: new SpriteAnimation(tile(0, 16), 2, .4),
walk: new SpriteAnimation(tile(2, 16), 4, .1),
attack: new SpriteAnimation(tile(6, 16), 3, .05).play(),
});
hero.set('attack', ()=> hero.set('idle')); // back to idle when the attack ends
// in update: this.tileInfo = hero.tileInfo;Members
clip
The clip showing now
- Source
clips
Properties| Type | Description |
|---|---|
| Object.<string, SpriteAnimation> | The clips by name |
- Source
frame
The frame of the clip showing now
- Source
isDone
True once the clip showing now is a play that has ended
- Source
name
Properties| Type | Description |
|---|---|
| string | The name of the clip showing now |
- Source
tileInfo
The tile of the frame showing now
- Source
Methods
set(name, onEndopt) → {SpriteAnimator}
Show a clip, starting it over in its own mode unless it is showing and has not ended
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name | string | The clip's name | |
onEnd | function | <optional> | Called once when a play clip ends, as with SpriteAnimation.play |
- Source
Returns:
- Type:
- SpriteAnimator