Add support for simple periodic sprite animations
This commit is contained in:
parent
426b2c37ff
commit
b83b596b0f
7 changed files with 90 additions and 22 deletions
|
@ -1,19 +1,29 @@
|
|||
import { Collision } from './collision';
|
||||
|
||||
export interface EntityAnimation {
|
||||
readonly sequence: ReadonlyArray<[number, number]>;
|
||||
}
|
||||
|
||||
export interface EntityDataInput {
|
||||
readonly sprite: string;
|
||||
readonly anchor?: [number, number];
|
||||
readonly collision?: Collision[];
|
||||
readonly frames?: number;
|
||||
readonly animation?: EntityAnimation;
|
||||
}
|
||||
|
||||
export class EntityData {
|
||||
public readonly sprite: string;
|
||||
public readonly anchor: [number, number];
|
||||
public readonly collision: Collision[];
|
||||
public readonly frames: number;
|
||||
public readonly animation?: EntityAnimation;
|
||||
|
||||
constructor(input: EntityDataInput) {
|
||||
this.sprite = input.sprite;
|
||||
this.anchor = input.anchor || [0.5, 0.5];
|
||||
this.collision = input.collision || [];
|
||||
this.frames = input.frames || 1;
|
||||
this.animation = input.animation;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue