fix(CATS) 角色动画测试场景键盘移动问题修复

This commit is contained in:
chicrobot committed 2026-01-09 14:11:33 +08:00
1 parent 61cbebec3e
commit 91ead45d5d
1 file changed
+3 -28
+3 -28
View File
@@ -12,7 +12,7 @@ import Unit from '../objects/Unit.js';
export default class CharacterAnimationTestScene extends Phaser.Scene {
constructor() {
super({ key: 'CharacterAnimationTestScene' });
this.tileSize = 32; // 瓦片大小
this.tileSize = 16; // 瓦片大小
this.player = null; // 玩家角色
this.inputSystem = null; // 输入系统
this.selectionSystem = null; // 选择系统
@@ -76,15 +76,6 @@ export default class CharacterAnimationTestScene extends Phaser.Scene {
// 显示提示信息
this.showInstructions();
// 添加相机移动控制
this.cameraSpeed = 2;
this.cameraKeys = this.input.keyboard.addKeys({
up: Phaser.Input.Keyboard.KeyCodes.W,
down: Phaser.Input.Keyboard.KeyCodes.S,
left: Phaser.Input.Keyboard.KeyCodes.A,
right: Phaser.Input.Keyboard.KeyCodes.D
});
}
/**
@@ -176,9 +167,7 @@ export default class CharacterAnimationTestScene extends Phaser.Scene {
*/
setupInput() {
// 只保留必要的按键监听,键盘移动由InputSystem处理
this.keys = {
space: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE)
};
this.cursors = this.input.keyboard.createCursorKeys();
// 切换角色按钮
this.createButton(this.sys.game.config.width - 200, 100, '切换角色', () => {
@@ -285,20 +274,6 @@ export default class CharacterAnimationTestScene extends Phaser.Scene {
// 更新输入系统
this.inputSystem.update();
// 更新相机移动
if (this.cameraKeys.left.isDown) {
this.cameras.main.scrollX -= this.cameraSpeed;
}
if (this.cameraKeys.right.isDown) {
this.cameras.main.scrollX += this.cameraSpeed;
}
if (this.cameraKeys.up.isDown) {
this.cameras.main.scrollY -= this.cameraSpeed;
}
if (this.cameraKeys.down.isDown) {
this.cameras.main.scrollY += this.cameraSpeed;
}
// 更新所有单位
this.unitGroup.getChildren().forEach(unit => {
if (unit.update) {
@@ -311,7 +286,7 @@ export default class CharacterAnimationTestScene extends Phaser.Scene {
});
// 按空格键返回启动场景
if (this.keys.space.isDown) {
if (this.cursors.space.isDown) {
this.scene.start('BootScene');
}
}