Files
pixelheros/assets/script/game/hero/HeroSpine.ts
walkpan 81f55a796d refactor(hero): 优化英雄对象池管理及视图初始化
- 在Monster类中实现多键对象池管理,提升英雄节点复用效率
- 将HeroViewComp的初始化逻辑提取到独立init方法,便于对象池复用时重置状态
- 移除HeroSpine中冗余的onDestroy方法
- 修复HeroViewComp中方向缩放计算问题,确保scale.x为正
- 优化碰撞体启用逻辑,延迟一帧确保物理系统正确注册
- 清理HeroViewComp中残留的定时器和缓动
2026-01-02 23:27:05 +08:00

90 lines
1.7 KiB
TypeScript

import { Color, Component, EventTouch, Vec3, _decorator ,} from "cc";
import HeroAnmComp from "./HeroAnmComp";
const { ccclass, property } = _decorator;
@ccclass('HeroSpine')
export class HeroSpine extends Component {
@property(HeroAnmComp)
anm: HeroAnmComp = null;
status:string="idle";
onLoad() {
// 角色控制组件
}
protected start(): void {
this.move();
}
/** 初始化动画 */
protected initAnimator() {
}
in_playing(){
}
change_status(value:string){
this.status=value
}
change_default(value:string){
}
default() {
}
idle(){
// console.log("change to idle",this.status);
// console.log("do Idle");
if(this.status=="idle") return
this.status="idle"
this.anm.idle()
}
atk() {
// console.log("do atk");
this.anm.atk()
}
max(){
// console.log("do max");
this.anm.max()
}
play(name:string){
switch(name){
case "max":
this.max()
break
case "atk":
this.atk()
break
case "idle":
this.idle()
break
case "move":
this.move()
break
}
}
do_atked(){
this.anm.atked()
}
dead(){
// console.log("do dead");
this.anm.dead()
}
do_buff(){
this.anm.buff()
}
buff(){
this.anm.buff()
}
move(){
// console.log("change to move",this.status);
if(this.status=="move") return
this.status="move"
this.anm.move()
}
}