mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-30 06:41:29 +08:00
fix(CATS) 角色动画测试场景键盘移动问题修复
This commit is contained in:
1 parent
61cbebec3e
commit
91ead45d5d
1 file changed
+3
-28
@@ -12,7 +12,7 @@ import Unit from '../objects/Unit.js';
|
|||||||
export default class CharacterAnimationTestScene extends Phaser.Scene {
|
export default class CharacterAnimationTestScene extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
super({ key: 'CharacterAnimationTestScene' });
|
super({ key: 'CharacterAnimationTestScene' });
|
||||||
this.tileSize = 32; // 瓦片大小
|
this.tileSize = 16; // 瓦片大小
|
||||||
this.player = null; // 玩家角色
|
this.player = null; // 玩家角色
|
||||||
this.inputSystem = null; // 输入系统
|
this.inputSystem = null; // 输入系统
|
||||||
this.selectionSystem = null; // 选择系统
|
this.selectionSystem = null; // 选择系统
|
||||||
@@ -76,15 +76,6 @@ export default class CharacterAnimationTestScene extends Phaser.Scene {
|
|||||||
|
|
||||||
// 显示提示信息
|
// 显示提示信息
|
||||||
this.showInstructions();
|
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() {
|
setupInput() {
|
||||||
// 只保留必要的按键监听,键盘移动由InputSystem处理
|
// 只保留必要的按键监听,键盘移动由InputSystem处理
|
||||||
this.keys = {
|
this.cursors = this.input.keyboard.createCursorKeys();
|
||||||
space: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE)
|
|
||||||
};
|
|
||||||
|
|
||||||
// 切换角色按钮
|
// 切换角色按钮
|
||||||
this.createButton(this.sys.game.config.width - 200, 100, '切换角色', () => {
|
this.createButton(this.sys.game.config.width - 200, 100, '切换角色', () => {
|
||||||
@@ -285,20 +274,6 @@ export default class CharacterAnimationTestScene extends Phaser.Scene {
|
|||||||
// 更新输入系统
|
// 更新输入系统
|
||||||
this.inputSystem.update();
|
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 => {
|
this.unitGroup.getChildren().forEach(unit => {
|
||||||
if (unit.update) {
|
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');
|
this.scene.start('BootScene');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user