2020-04-12 16:12:08 +02:00
|
|
|
import {Textures} from "../Game/GameScene";
|
|
|
|
|
2020-04-07 19:23:21 +02:00
|
|
|
interface AnimationData {
|
|
|
|
key: string;
|
|
|
|
frameRate: number;
|
|
|
|
repeat: number;
|
|
|
|
frameModel: string; //todo use an enum
|
|
|
|
frameStart: number;
|
|
|
|
frameEnd: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum PlayerAnimationNames {
|
|
|
|
WalkDown = 'down',
|
|
|
|
WalkLeft = 'left',
|
|
|
|
WalkUp = 'up',
|
|
|
|
WalkRight = 'right',
|
2020-04-07 20:46:30 +02:00
|
|
|
}
|
2020-04-07 19:23:21 +02:00
|
|
|
|
2020-05-04 01:48:14 +02:00
|
|
|
export const getPlayerAnimations = (name: string = Textures.Player): AnimationData[] => {
|
2020-04-07 19:23:21 +02:00
|
|
|
return [{
|
2020-05-06 02:13:00 +02:00
|
|
|
key: `${name}-${PlayerAnimationNames.WalkDown}`,
|
2020-05-04 01:48:14 +02:00
|
|
|
frameModel: name,
|
2020-04-07 19:23:21 +02:00
|
|
|
frameStart: 0,
|
|
|
|
frameEnd: 2,
|
|
|
|
frameRate: 10,
|
|
|
|
repeat: -1
|
|
|
|
}, {
|
2020-05-06 01:50:01 +02:00
|
|
|
key: `${name}-${PlayerAnimationNames.WalkLeft}`,
|
2020-05-04 01:48:14 +02:00
|
|
|
frameModel: name,
|
2020-04-07 19:23:21 +02:00
|
|
|
frameStart: 3,
|
|
|
|
frameEnd: 5,
|
|
|
|
frameRate: 10,
|
|
|
|
repeat: -1
|
|
|
|
}, {
|
2020-05-06 01:50:01 +02:00
|
|
|
key: `${name}-${PlayerAnimationNames.WalkRight}`,
|
2020-05-04 01:48:14 +02:00
|
|
|
frameModel: name,
|
2020-04-07 19:23:21 +02:00
|
|
|
frameStart: 6,
|
|
|
|
frameEnd: 8,
|
|
|
|
frameRate: 10,
|
|
|
|
repeat: -1
|
|
|
|
}, {
|
2020-05-06 01:50:01 +02:00
|
|
|
key: `${name}-${PlayerAnimationNames.WalkUp}`,
|
2020-05-04 01:48:14 +02:00
|
|
|
frameModel: name,
|
2020-04-07 19:23:21 +02:00
|
|
|
frameStart: 9,
|
|
|
|
frameEnd: 11,
|
|
|
|
frameRate: 10,
|
|
|
|
repeat: -1
|
|
|
|
}];
|
|
|
|
};
|