50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
/*
|
||
* @Author: dgflash
|
||
* @Date: 2022-08-04 15:08:35
|
||
* @LastEditors: dgflash
|
||
* @LastEditTime: 2022-08-04 15:26:38
|
||
*/
|
||
import { sp, _decorator } from "cc";
|
||
import AnimatorSpine from "../../../../extensions/oops-plugin-framework/assets/libs/animator/AnimatorSpine";
|
||
|
||
const { ccclass, property, requireComponent, disallowMultiple } = _decorator;
|
||
|
||
/**
|
||
* Spine状态机组件(主状态机),trackIndex为0
|
||
*/
|
||
@ccclass
|
||
@disallowMultiple
|
||
@requireComponent(sp.Skeleton)
|
||
export default class HeroAnmComp extends AnimatorSpine {
|
||
|
||
private animName: string = "Idle";
|
||
private loop: boolean = true;
|
||
|
||
start() {
|
||
|
||
super.start();
|
||
}
|
||
|
||
lateUpdate(dt: number) {
|
||
|
||
}
|
||
|
||
/**
|
||
* 播放动画
|
||
* @override
|
||
* @param animName 动画名
|
||
* @param loop 是否循环播放
|
||
*/
|
||
protected playAnimation(animName: string, loop: boolean) {
|
||
if (animName) {
|
||
this.animName = animName;
|
||
this.loop = loop;
|
||
|
||
this._spine.setAnimation(0, animName, loop);
|
||
}
|
||
else {
|
||
this._spine.clearTrack(0);
|
||
}
|
||
}
|
||
|
||
} |