/* * @Author: dgflash * @Date: 2022-08-04 15:08:35 * @LastEditors: dgflash * @LastEditTime: 2022-08-04 15:26:38 */ import { sp, _decorator ,Component} from "cc"; const { ccclass, property, requireComponent, disallowMultiple } = _decorator; /** * Spine状态机组件(主状态机),trackIndex为0 */ @ccclass @disallowMultiple @requireComponent(sp.Skeleton) export default class RoleSpineAnimator extends Component { private animName: string = "idle"; private loop: boolean = true; start() { console.log("RoleSpineAnimator start"); this.playAnimation(this.animName, this.loop); } lateUpdate(dt: number) { this.playAnimation(this.animName, this.loop); } play(animName: string, loop: boolean) { if (animName) { this.animName = animName; this.loop = loop; } else { } } /** * 播放动画 * @override * @param animName 动画名 * @param loop 是否循环播放 */ protected playAnimation(animName: string, loop: boolean) { if (animName) { this.animName = animName; this.loop = loop; } else { } } }