cocos-animator/animator-runtime/AnimatorAvatar.ts

52 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-01-19 14:30:12 +00:00
import AnimatorBase, { AnimationPlayer } from "./core/AnimatorBase";
import AnimatorStateLogic from "./core/AnimatorStateLogic";
const { ccclass, property, requireComponent } = cc._decorator;
/** 纸娃娃系统状态机组件 */
@ccclass
export default class AnimatorAvatar extends AnimatorBase {
/**
* 0-3
* - onStateChangeCall
* - stateLogicMap
* - animationPlayer
* @override
*/
public onInit(...args: Array<Map<string, AnimatorStateLogic> | ((fromState: string, toState: string) => void) | AnimationPlayer>) {
if (this._hasInit) {
return;
}
this._hasInit = true;
this.initArgs(...args);
if (this.AssetRawUrl !== null) {
this.initJson(this.AssetRawUrl.json);
}
}
/**
*
* @override
* @param animName
* @param loop
*/
protected playAnimation(animName: string, loop: boolean) {
if (this._animationPlayer) {
this._animationPlayer.playAnimation(animName, loop);
}
}
/**
*
* @override
* @param scale
*/
protected scaleTime(scale: number) {
if (this._animationPlayer) {
this._animationPlayer.scaleTime(scale);
}
}
}