rewrote the app code to more easily allow for collisions
This commit is contained in:
parent
241cbd720a
commit
6e27377b07
10 changed files with 139 additions and 268 deletions
|
@ -1,7 +1,10 @@
|
|||
import {Textures} from "../Game/GameScene";
|
||||
import {PlayableCaracter} from "../Entity/PlayableCaracter";
|
||||
|
||||
interface AnimationData {
|
||||
key: string;
|
||||
frameRate: number;
|
||||
repeat: number;
|
||||
//repeat: number;
|
||||
frameModel: string; //todo use an enum
|
||||
frameStart: number;
|
||||
frameEnd: number;
|
||||
|
@ -15,42 +18,39 @@ export enum PlayerAnimationNames {
|
|||
None = 'none',
|
||||
}
|
||||
|
||||
export const getPlayerAnimations = (PlayerValue : string): AnimationData[] => {
|
||||
export const getPlayerAnimations = (): AnimationData[] => {
|
||||
return [{
|
||||
key: PlayerAnimationNames.WalkDown,
|
||||
frameModel: PlayerValue,
|
||||
frameModel: Textures.Player,
|
||||
frameStart: 0,
|
||||
frameEnd: 2,
|
||||
frameRate: 10,
|
||||
repeat: -1
|
||||
//repeat: -1
|
||||
}, {
|
||||
key: PlayerAnimationNames.WalkLeft,
|
||||
frameModel: PlayerValue,
|
||||
frameModel: Textures.Player,
|
||||
frameStart: 3,
|
||||
frameEnd: 5,
|
||||
frameRate: 10,
|
||||
repeat: -1
|
||||
//repeat: -1
|
||||
}, {
|
||||
key: PlayerAnimationNames.WalkRight,
|
||||
frameModel: PlayerValue,
|
||||
frameModel: Textures.Player,
|
||||
frameStart: 6,
|
||||
frameEnd: 8,
|
||||
frameRate: 10,
|
||||
repeat: -1
|
||||
//repeat: -1
|
||||
}, {
|
||||
key: PlayerAnimationNames.WalkUp,
|
||||
frameModel: PlayerValue,
|
||||
frameModel: Textures.Player,
|
||||
frameStart: 9,
|
||||
frameEnd: 11,
|
||||
frameRate: 10,
|
||||
repeat: -1
|
||||
//repeat: -1
|
||||
}];
|
||||
};
|
||||
|
||||
export const playAnimation = (Player : Phaser.GameObjects.Sprite, direction : string) => {
|
||||
if (!Player.anims.currentAnim || Player.anims.currentAnim.key !== direction) {
|
||||
Player.anims.play(direction);
|
||||
} else if (direction === PlayerAnimationNames.None && Player.anims.currentAnim) {
|
||||
Player.anims.currentAnim.destroy();
|
||||
}
|
||||
export const playAnimation = (Player : PlayableCaracter, direction : string) => {
|
||||
//if (direction === 'none') return;
|
||||
//Player.play(direction, true);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue