diff --git a/assets/script/game/hero/HeroAnmComp.ts b/assets/script/game/hero/HeroAnmComp.ts index 0e0c1ea0..0d6a66be 100644 --- a/assets/script/game/hero/HeroAnmComp.ts +++ b/assets/script/game/hero/HeroAnmComp.ts @@ -17,6 +17,12 @@ export default class HeroAnmComp extends Component{ this.anmcon.on(Animation.EventType.FINISHED, this.onAnimationFinished, this); } + onDestroy() { + if (this.anmcon) { + this.anmcon.off(Animation.EventType.FINISHED, this.onAnimationFinished, this); + } + } + stop () { this._hasStop = true; diff --git a/assets/script/game/map/MInfoComp.ts b/assets/script/game/map/MInfoComp.ts deleted file mode 100644 index 86aff305..00000000 --- a/assets/script/game/map/MInfoComp.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { _decorator, Component, Label, Node } from 'cc'; -import { oops } from 'db://oops-framework/core/Oops'; -import { GameEvent } from '../common/config/GameEvent'; -import { smc } from '../common/SingletonModuleComp'; -const { ccclass, property } = _decorator; - -@ccclass('MInfoComp') -export class MInfoComp extends Component { - protected onLoad(): void { - oops.message.on(GameEvent.MISSION_UPDATE,this.onMissionUpdate,this); - this.update_mission(smc.data.mission) - } - start() { - this.update_mission(smc.data.mission) - } - onMissionUpdate(event:string,data:any){ - this.update_mission(smc.data.mission) - } - - update_mission(mission:number){ - this.node.getChildByName("mission").getComponent(Label).string="第 "+mission.toString()+" 关" - } - - -} - - diff --git a/assets/script/game/map/MInfoComp.ts.meta b/assets/script/game/map/MInfoComp.ts.meta deleted file mode 100644 index f518ccf8..00000000 --- a/assets/script/game/map/MInfoComp.ts.meta +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ver": "4.0.24", - "importer": "typescript", - "imported": true, - "uuid": "45cb2edd-7958-45ba-8eb9-bcf587448e5c", - "files": [], - "subMetas": {}, - "userData": {} -} diff --git a/assets/script/game/map/TopComp.ts b/assets/script/game/map/TopComp.ts index 4f094a15..c90afe63 100644 --- a/assets/script/game/map/TopComp.ts +++ b/assets/script/game/map/TopComp.ts @@ -20,6 +20,10 @@ export class topComp extends Component { .start() } + onDestroy(){ + oops.message.off(GameEvent.GOLD_UPDATE,this.onGoldUpdate,this); + } + update(deltaTime: number) { diff --git a/assets/script/game/map/move.ts b/assets/script/game/map/move.ts index 494e6c4c..29253780 100644 --- a/assets/script/game/map/move.ts +++ b/assets/script/game/map/move.ts @@ -37,6 +37,12 @@ export class move extends Component { this.setInitialPosition() } } + + onDestroy() { + oops.message.off(GameEvent.MAP_MOVE_END_LEFT, this.onMapMoveEndLeft, this); + oops.message.off(GameEvent.MAP_MOVE_END_RIGHT, this.onMapMoveEndRight, this); + } + /** * 根据移动方向设置初始位置 */