Interface AnimationOptions

Animation configuration

const walkAnimation = new Animation({
image: "walk.png",
slice: { size: new Vector2(32, 32) },
frames: [0, 1, 2, 3, 4, 5],
fps: 12,
loop: true
});

const idleAnimation = new Animation({
image: "idle.png",
slice: { size: new Vector2(32, 32) },
frames: [6, 7, 8, 9],
fps: 8,
loop: true
});

const animator = new Animator({
animations: new Map([
["walk", walkAnimation],
["idle", idleAnimation]
]),
animation: "idle",
speed: 1,
playing: true
});
interface AnimationOptions {
    fps?: number;
    frames?: number[];
    image:
        | string
        | string[]
        | HTMLImageElement
        | HTMLImageElement[];
    loop?: boolean;
    slice?: {
        offset?: Vector2;
        padding?: Vector2;
        size: Vector2;
    };
}

Properties

fps?: number
frames?: number[]
image:
    | string
    | string[]
    | HTMLImageElement
    | HTMLImageElement[]
loop?: boolean
slice?: {
    offset?: Vector2;
    padding?: Vector2;
    size: Vector2;
}