Files
pixelheros/assets/script/game/hero/HeroAnmComp.ts
panw 3a8f015a78 refactor: 移除调试日志并统一使用日志工具
- 删除多个文件中的 console.log/console.warn/console.error 调试输出
- 将日志输出统一替换为 mLogger 工具,支持调试模式控制
- 清理注释掉的调试代码和空方法体
2026-02-03 16:49:24 +08:00

65 lines
2.0 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 default_anim:string='Idle'
anms:any[]=["idle","move","stun","dead","buff","atk0","atk1","atk2","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"&&state.name!="dead"&&state.name!="stun"){
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) return
// if(this.anmcon.getState("atk0").isPlaying) return
this.anmcon.play("atk0")
}
max () {
if(this.anmcon.getState("max0").isPlaying) return
this.anmcon.play("max0")
}
idle () {
if(this.anmcon.getState("idle").isPlaying) return
this.anmcon.play("idle")
this.default_anim='idle'
}
buff(){
if(this.anmcon.getState("max0").isPlaying) return
this.anmcon.play("buff")
}
dead(){
if(this.anmcon.getState("dead").isPlaying) return
this.anmcon.play("dead")
}
}