SpriteAnimator - A character's animations by name, like idle, walk and attack, and the one showing now
- Each clip is a SpriteAnimation and keeps its own mode, loop, play or pingPong
- set starts a clip over only when it changes or a play of it has ended, so it can be called every update
- Read tileInfo each frame for the frame to draw, as with a SpriteAnimation
Create an animator from its clips, showing the first one
clips Object<string, SpriteAnimation>The clips by name
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;
The frame of the clip showing now
True once the clip showing now is a play that has ended
The name of the clip showing now
The tile of the frame showing now
Show a clip, starting it over in its own mode unless it is showing and has not ended
name stringThe clip's name
onEnd function optionalCalled once when a play clip ends, as with SpriteAnimation.play