Function: showAnimatedSprite()
Call Signature
> showAnimatedSprite(alias, options?): Promise<AnimatedSprite>
Defined in: src/canvas/functions/animated-sprite-utility.ts:131
Add and show an animated sprite in the canvas, using alias as the spritesheet alias. The animation starts playing, unless autoPlay: false is passed.
Parameters
alias
string
The unique alias of the component, also used as the alias of the spritesheet (it must be registered in the asset cache or manifest).
options?
The options of the animated sprite.
Returns
Promise<AnimatedSprite>
This function returns an AnimatedSprite that you can use to manipulate the component.
Throws
when alias is not registered in the asset cache.
Example
Assets.add({ alias: "fighter", src: "https://pixijs.com/assets/spritesheet/fighter.json" });
await showAnimatedSprite("fighter", { align: 0.5, animationSpeed: 0.4 });Call Signature
> showAnimatedSprite(alias, source?, options?): Promise<AnimatedSprite>
Defined in: src/canvas/functions/animated-sprite-utility.ts:154
Add and show an animated sprite in the canvas. This function is a combination of addAnimatedSprite and AnimatedSprite.load.
The animation starts playing, unless autoPlay: false is passed in the options.
Parameters
alias
string
The unique alias of the animated sprite. You can use this alias to refer to this component.
source?
string | AnimatedSpriteSource
The frames of the animation: the alias/URL of a spritesheet, or an AnimatedSpriteSource.
If you don't provide it, or it has no spritesheet and no frames (e.g. { animation: "walk" }), the alias is used as the spritesheet alias.
options?
The options of the animated sprite.
Returns
Promise<AnimatedSprite>
This function returns an AnimatedSprite that you can use to manipulate the component.
Throws
when source is not provided and alias is not registered in the asset cache.
Example
Assets.add({ alias: "fighter", src: "https://pixijs.com/assets/spritesheet/fighter.json" });
// a different alias for the component: (alias, spritesheetAlias, options)
await showAnimatedSprite("myFighter", "fighter", { align: 0.5, anchor: 0.5 });
// only some frames of the spritesheet
await showAnimatedSprite("rolling", { spritesheet: "fighter", frames: ["rollSequence0000.png", "rollSequence0001.png"] });