Interface: AnimatedSpriteSource
Defined in: src/canvas/interfaces/AnimatedSpriteSource.ts:41
A serializable description of the frames of an AnimatedSprite. It only contains asset aliases/URLs and frame names, so it can be saved in the game state and used to rebuild the animation when a save is loaded or the player goes back in the history.
The frames are resolved in this order:
spritesheet+animation: the frames ofspritesheet.animations[animation];spritesheet+frames: the listed frames of the spritesheet;spritesheetonly: all the frames of the spritesheet, sorted in natural order (frame2beforeframe10);framesonly: each frame is a texture alias or URL.
Example
Assets.add({ alias: "explosion", src: "https://pixijs.com/assets/spritesheet/mc.json" });
// all the frames of a spritesheet
const explosion: AnimatedSpriteSource = { spritesheet: "explosion" };
// a named animation of a spritesheet
const walk: AnimatedSpriteSource = { spritesheet: "hero", animation: "walk" };
// some frames of a spritesheet, with custom durations
const blink: AnimatedSpriteSource = {
spritesheet: "hero",
frames: [{ texture: "eyes_open.png", time: 2000 }, { texture: "eyes_closed.png", time: 100 }],
};
// separate images
const flag: AnimatedSpriteSource = { frames: ["flag1", "flag2", "flag3"] };Properties
animation?
> optional animation?: string
Defined in: src/canvas/interfaces/AnimatedSpriteSource.ts:50
The name of an animation defined in the animations field of the spritesheet.
Requires spritesheet.
frames?
> optional frames?: (string | AnimatedSpriteFrameSource)[]
Defined in: src/canvas/interfaces/AnimatedSpriteSource.ts:56
The frames to use, in order. If spritesheet is set, they are frame names of the spritesheet, otherwise they are texture aliases or URLs. Use an AnimatedSpriteFrameSource to set the duration of a single frame.
spritesheet?
> optional spritesheet?: string
Defined in: src/canvas/interfaces/AnimatedSpriteSource.ts:45
The alias or URL of a spritesheet JSON (a PixiJS Spritesheet).
useFrameDurations?
> optional useFrameDurations?: boolean
Defined in: src/canvas/interfaces/AnimatedSpriteSource.ts:63
If true, each frame uses the duration (in milliseconds) stored in the spritesheet JSON, as exported
by Aseprite or TexturePacker. A frame without a duration lasts DEFAULT_ANIMATED_SPRITE_FRAME_TIME ms.
The animationSpeed of the component is still applied as a multiplier.
Default
false