Improve battle unit immersion

This commit is contained in:
2026-06-28 23:15:45 +09:00
parent 66fc9984e5
commit 501a97706f
185 changed files with 196 additions and 65 deletions

View File

@@ -5,6 +5,7 @@ export type UnitDirection = 'south' | 'east' | 'north' | 'west';
const unitWalkFrameCount = 4;
export const unitSheetFrameSize = 313;
const unitWalkFrameRate = 8;
const unitIdleFrameRate = 3;
const unitSheetRows: Record<UnitDirection, number> = {
south: 0,
east: 1,
@@ -96,7 +97,10 @@ export function ensureUnitAnimations(scene: Phaser.Scene, keys: Iterable<string>
key,
frame: unitSheetRows[direction] * unitWalkFrameCount + frameIndex
}));
const idleFrame = [{ key, frame: unitSheetRows[direction] * unitWalkFrameCount }];
const idleFrames = [0, 1, 0, 3].map((frameIndex) => ({
key,
frame: unitSheetRows[direction] * unitWalkFrameCount + frameIndex
}));
const walkAnimationKey = `${key}-walk-${direction}`;
const idleAnimationKey = `${key}-idle-${direction}`;
@@ -112,9 +116,9 @@ export function ensureUnitAnimations(scene: Phaser.Scene, keys: Iterable<string>
if (!scene.anims.exists(idleAnimationKey)) {
scene.anims.create({
key: idleAnimationKey,
frames: idleFrame,
frameRate: 1,
repeat: 0
frames: idleFrames,
frameRate: unitIdleFrameRate,
repeat: -1
});
}
});