|
@@ -48,14 +48,8 @@ export class CharacterManager extends Component {
|
|
|
this.initialPosition.x += 400; // 初始位置的x坐标增加400
|
|
|
}
|
|
|
|
|
|
- // 设置按钮事件监听
|
|
|
- if (this.letPassButton) {
|
|
|
- this.letPassButton.node.on(Button.EventType.CLICK, this.moveCharacterRight, this);
|
|
|
- }
|
|
|
-
|
|
|
- if (this.dismissButton) {
|
|
|
- this.dismissButton.node.on(Button.EventType.CLICK, this.moveCharacterLeft, this);
|
|
|
- }
|
|
|
+ // 不再直接绑定按钮事件,这会导致回调函数丢失
|
|
|
+ // 这些按钮事件在GameFlowManager中处理
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -112,7 +106,9 @@ export class CharacterManager extends Component {
|
|
|
* @param onComplete 移动完成后的回调函数
|
|
|
*/
|
|
|
public moveCharacterRight(onComplete?: () => void): void {
|
|
|
- if (!this.characterNode || !this.initialPosition) return;
|
|
|
+ if (!this.characterNode || !this.initialPosition) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
// 隐藏对话框
|
|
|
if (this.dialogueManager) {
|
|
@@ -155,7 +151,9 @@ export class CharacterManager extends Component {
|
|
|
* @param onComplete 移动完成后的回调函数
|
|
|
*/
|
|
|
public moveCharacterLeft(onComplete?: () => void): void {
|
|
|
- if (!this.characterNode || !this.initialPosition) return;
|
|
|
+ if (!this.characterNode || !this.initialPosition) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
// 隐藏对话框
|
|
|
if (this.dialogueManager) {
|
|
@@ -255,13 +253,6 @@ export class CharacterManager extends Component {
|
|
|
}
|
|
|
|
|
|
onDestroy() {
|
|
|
- // 移除按钮事件监听
|
|
|
- if (this.letPassButton) {
|
|
|
- this.letPassButton.node.off(Button.EventType.CLICK, this.moveCharacterRight, this);
|
|
|
- }
|
|
|
-
|
|
|
- if (this.dismissButton) {
|
|
|
- this.dismissButton.node.off(Button.EventType.CLICK, this.moveCharacterLeft, this);
|
|
|
- }
|
|
|
+ // 不再需要移除这些事件监听
|
|
|
}
|
|
|
}
|