| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import { _decorator, Component, Node, KeyCode, input, Input, EventKeyboard } from 'cc';
- import EventBus, { GameEvents } from '../Core/EventBus';
- const { ccclass, property } = _decorator;
- /**
- * 小球暂停模式测试脚本
- * 用于测试技能选择暂停和底板选择暂停的不同表现
- */
- @ccclass('BallPauseTest')
- export class BallPauseTest extends Component {
- start() {
- // 监听键盘事件
- input.on(Input.EventType.KEY_DOWN, this.onKeyDown, this);
-
- console.log('[BallPauseTest] 测试脚本已启动');
- console.log('[BallPauseTest] 按键说明:');
- console.log('[BallPauseTest] 1 - 触发技能选择暂停(所有小球停止)');
- console.log('[BallPauseTest] 2 - 触发底板选择暂停(所有小球继续运动)');
- console.log('[BallPauseTest] 3 - 恢复游戏');
- console.log('[BallPauseTest] 4 - 创建额外小球(用于测试多球暂停)');
- }
- private onKeyDown(event: EventKeyboard) {
- const eventBus = EventBus.getInstance();
-
- switch (event.keyCode) {
- case KeyCode.DIGIT_1:
- console.log('[BallPauseTest] 触发技能选择暂停 - 所有小球应该停止运动');
- eventBus.emit(GameEvents.GAME_PAUSE_SKILL_SELECTION);
- break;
-
- case KeyCode.DIGIT_2:
- console.log('[BallPauseTest] 触发底板选择暂停 - 所有小球应该继续运动');
- eventBus.emit(GameEvents.GAME_PAUSE_BLOCK_SELECTION);
- break;
-
- case KeyCode.DIGIT_3:
- console.log('[BallPauseTest] 恢复游戏 - 恢复所有小球运动');
- eventBus.emit(GameEvents.GAME_RESUME);
- break;
-
- case KeyCode.DIGIT_4:
- console.log('[BallPauseTest] 创建额外小球');
- eventBus.emit(GameEvents.BALL_CREATE_ADDITIONAL);
- break;
- }
- }
- onDestroy() {
- // 清理键盘事件监听
- input.off(Input.EventType.KEY_DOWN, this.onKeyDown, this);
- }
- }
|