indexFunctions
Function: getAnimatedSpriteFrames()
> getAnimatedSpriteFrames(source): Promise<Texture<TextureSource<any>>[] | FrameObject[]>
Defined in: src/canvas/functions/spritesheet-utility.ts:112
Resolve an AnimatedSpriteSource into the frames of a PixiJS AnimatedSprite.
Parameters
source
The description of the frames.
Returns
Promise<Texture<TextureSource<any>>[] | FrameObject[]>
A Texture[], or a FrameObject[] if at least one frame has a duration
(a frame with time, or useFrameDurations: true).
Throws
when the spritesheet, the animation, or a frame can't be found, or the source has no frames.
Example
import { AnimatedSprite as PixiAnimatedSprite } from "pixi.js";
Assets.add({ alias: "hero", src: "https://example.com/assets/hero.json" });
const frames = await getAnimatedSpriteFrames({ spritesheet: "hero", animation: "walk" });
// e.g. inside a custom component, or with a plain PixiJS AnimatedSprite
const sprite = new PixiAnimatedSprite(frames);