import { _decorator, Component, director, Node, sp } from 'cc'; const { ccclass, property } = _decorator; @ccclass('jige') export class jige extends Component { anim: sp.Skeleton = null; protected onLoad(): void { this.anim = this.node.getChildByName('amin').getComponent(sp.Skeleton); } protected onEnable(): void { this.anim.setAnimation(0, '常态待机', true); } protected update(dt: number): void { // if (director.getTotalFrames() % 180 === 0 && this.anim.animation === '常态待机') { // this.anim.setAnimation(0, '待机', false); // this.anim.setCompleteListener(() => { // this.anim.setAnimation(0, '常态待机', true); // this.anim.setCompleteListener(null); // }); // } } /**播放得意动画 */ playHappyAnim() { console.log('playHappyAnim得意'); this.anim.setAnimation(0, '得意', false); this.anim.setCompleteListener(() => { this.anim.setAnimation(0, '常态待机', true); this.anim.setCompleteListener(null); }); } }