- 将 HInfoComp 组件改为继承自 CCComp 并注册为 ECS 组件 - 新增动画锁定标志 isMoving 防止快速点击引起动画冲突 - 添加 moveTimeoutId 用于管理动画队列异步操作,避免重叠 - 优化英雄切换的移动动画,缩短动画时长为0.2秒 - moveHeroesLeft 与 moveHeroesRight 方法增加动画锁定与异步取消逻辑 - 在切换英雄时调用 smc.updateFihgtHero 以更新当前战斗英雄状态 - 清理和销毁动画节点时更严格以避免残留和内存泄漏 - MissionHomeComp 中 mission_end 方法增加日志输出 - MissionHeroComp 去除了冗余空行,优化代码结构
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { _decorator, instantiate, Prefab, resources, Sprite, SpriteAtlas, UITransform } from "cc";
|
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
|
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
import { GameEvent } from "../common/config/GameEvent";
|
|
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/** 视图层对象 */
|
|
@ccclass('MissionHomeComp')
|
|
@ecs.register('MissionHome', false)
|
|
export class MissionHomeComp extends CCComp {
|
|
protected onLoad(): void {
|
|
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
|
}
|
|
/** 视图层逻辑代码分离演示 */
|
|
start() {
|
|
this.home_active()
|
|
}
|
|
onEnable(){
|
|
}
|
|
update(dt:number){
|
|
|
|
}
|
|
|
|
|
|
start_mission() {
|
|
oops.message.dispatchEvent(GameEvent.MissionStart, {})
|
|
this.node.active=false;
|
|
}
|
|
mission_end(){
|
|
console.log("[MissionHomeComp]=>mission_end")
|
|
this.home_active()
|
|
}
|
|
home_active(){
|
|
this.uodate_data()
|
|
this.node.active=true
|
|
this.btn_func("","fight")
|
|
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
|
|
}
|
|
uodate_data(){
|
|
|
|
}
|
|
isWxClient(){
|
|
return typeof wx !== 'undefined' && typeof (wx as any).getSystemInfoSync === 'function';
|
|
}
|
|
btn_func(e:string,data:any){
|
|
|
|
}
|
|
|
|
|
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
reset() {
|
|
this.node.destroy();
|
|
}
|
|
} |