/* * @Author: dgflash * @Date: 2022-08-04 15:08:35 * @LastEditors: dgflash * @LastEditTime: 2022-08-04 15:26:38 */ import { sp, _decorator ,Component} from "cc"; import { smc } from "../../common/SingletonModuleComp"; 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; private spine!: sp.Skeleton; start() { this.spine = this.getComponent(sp.Skeleton)!; console.log("RoleSpineAnimator start smc.heros",smc.heros); } lateUpdate(dt: number) { } getRandomInt(min: number, max: number): number { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; } play(animName: string, loop: boolean) { if (animName) { this.animName = animName; this.loop = loop; this.spine.setAnimation(0, this.animName, this.loop); } else { } } /** * 播放动画 * @override * @param animName 动画名 * @param loop 是否循环播放 */ protected playAnimation(animName: string, loop: boolean) { console.log("RoleSpineAnimator playAnimation"); if (animName) { console.log("RoleSpineAnimator playAnimation animName", animName); this.animName = animName; this.loop = loop; this.spine.setAnimation(0, this.animName, this.loop); } else { } } }