Files
pixelheros/assets/script/game/hero/HeroAnmComp.ts
panw 38f0863583 fix(hero): 移除死亡动画播放逻辑
移除 HeroSpine、HeroViewComp 和 HeroAnmComp 中与死亡动画相关的播放调用和状态检查。因为死亡动画可能已整合到其他特效或逻辑中,继续播放会导致视觉或逻辑冲突。
2026-04-01 09:15:53 +08:00

70 lines
2.1 KiB
TypeScript

import { _decorator, Animation, AnimationState, CCClass, Component, } from "cc";
import { HeroViewComp } from "./HeroViewComp";
import { FacSet } from "../common/config/GameSet";
import { FlashSprite } from "./hit-flash-white/scripts/FlashSprite";
const { ccclass, property } = _decorator;
@ccclass('HeroAnmComp')
export default class HeroAnmComp extends Component{
fsSprite:FlashSprite = null!;
private anmcon:any=null
private _hasStop = true;
private _atkIndex = 0;
private default_anim:string='idle'
anms:any[]=["idle","move","atk0","max0","max1"]
onLoad () {
this.anmcon=this.node.getComponent(Animation)
this.fsSprite = this.node.getComponent(FlashSprite);
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;
}
onAnimationFinished(type:Animation.EventType, state:AnimationState){
if(state.name!="idle"&&state.name!="move"){
this.anmcon.play(this.default_anim)
}
}
atked(){
this.fsSprite.clickFlash();
}
move () {
if(this.anmcon.getState("move").isPlaying) return
this.anmcon.play("move")
this.default_anim='move'
}
atk () {
if(this.anmcon.getState("max0").isPlaying||this.anmcon.getState("max1").isPlaying) return
this.anmcon.play(`atk0`)
}
max () {
if(this.anmcon.getState("max0").isPlaying||this.anmcon.getState("max1").isPlaying) return
this.anmcon.play("max0")
}
play(anm:string=""){
if(anm==="") return
if(this.anmcon.getState("max0").isPlaying||this.anmcon.getState("max1").isPlaying) return
this.anmcon.play(anm)
}
idle () {
if(this.anmcon.getState("idle").isPlaying) return
this.anmcon.play("idle")
this.default_anim='idle'
}
buff(){
if(this.anmcon.getState("max0").isPlaying||this.anmcon.getState("max1").isPlaying) return
this.anmcon.play("buff")
}
dead(){
}
}