Stabilize unit facing and movement feedback
This commit is contained in:
@@ -5,8 +5,6 @@ export type UnitDirection = 'south' | 'east' | 'north' | 'west';
|
||||
const unitWalkFrameCount = 4;
|
||||
export const unitSheetFrameSize = 313;
|
||||
const unitWalkFrameRate = 8;
|
||||
const unitIdleFrameRate = 4;
|
||||
|
||||
const unitSheetRows: Record<UnitDirection, number> = {
|
||||
south: 0,
|
||||
east: 1,
|
||||
@@ -98,6 +96,7 @@ export function ensureUnitAnimations(scene: Phaser.Scene, keys: Iterable<string>
|
||||
key,
|
||||
frame: unitSheetRows[direction] * unitWalkFrameCount + frameIndex
|
||||
}));
|
||||
const idleFrame = [{ key, frame: unitSheetRows[direction] * unitWalkFrameCount }];
|
||||
const walkAnimationKey = `${key}-walk-${direction}`;
|
||||
const idleAnimationKey = `${key}-idle-${direction}`;
|
||||
|
||||
@@ -113,9 +112,9 @@ export function ensureUnitAnimations(scene: Phaser.Scene, keys: Iterable<string>
|
||||
if (!scene.anims.exists(idleAnimationKey)) {
|
||||
scene.anims.create({
|
||||
key: idleAnimationKey,
|
||||
frames,
|
||||
frameRate: unitIdleFrameRate,
|
||||
repeat: -1
|
||||
frames: idleFrame,
|
||||
frameRate: 1,
|
||||
repeat: 0
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user