Files
pixelheros/assets/script/game/map/TopComp.ts
walkpan 9ab8ccdb92 refactor(组件): 添加组件销毁时的资源清理逻辑并移除无用文件
在TopComp、move和HeroAnmComp组件中添加onDestroy方法,用于清理事件监听
移除已不再使用的MInfoComp组件及其meta文件
2026-01-04 22:24:54 +08:00

34 lines
949 B
TypeScript

import { _decorator, Component, Label, Node, tween, v3 } from 'cc';
import { GameEvent } from '../common/config/GameEvent';
import { smc } from '../common/SingletonModuleComp';
import { BoxSet, NumberFormatter } from '../common/config/GameSet';
import { oops } from 'db://oops-framework/core/Oops';
const { ccclass, property } = _decorator;
@ccclass('topComp')
export class topComp extends Component {
protected onLoad(): void {
oops.message.on(GameEvent.GOLD_UPDATE,this.onGoldUpdate,this);
}
start() {
}
onGoldUpdate(event:string,data:any){
tween(this.node.getChildByName("bar").getChildByName("gold").getChildByName("num").getComponent(Label).node)
.to(0.1,{scale:v3(1.2,1.2,1)})
.to(0.1,{scale:v3(1,1,1)})
.start()
}
onDestroy(){
oops.message.off(GameEvent.GOLD_UPDATE,this.onGoldUpdate,this);
}
update(deltaTime: number) {
}
}