I am new to CocosCreator. I have an exported fbx model from Maya tool. After I imported it to CC I could see a prefab with cc.SkeletalAnimation as the image below.
I also have a script attached to the prefab but nothing happens after I click. How can I achieve it?
@ccclass('MermaidController')
export class MermaidController extends Component {
private _startAnim: boolean = false;
private _animation: SkeletalAnimation | null = null;
protected onLoad(): void {
this._animation = this.node.getComponent(SkeletalAnimation);
}
start() {
input.on(Input.EventType.MOUSE_UP, this.onMouseUp, this);
}
update(deltaTime: number) {
}
onMouseUp(event: EventMouse) {
if(event.getButton() === EventMouse.BUTTON_LEFT) {
console.log('start anim: ' + this._startAnim);
this._startAnim = true;
this._animation?.start();
console.log('start anim: ' + this._startAnim);
}
}
}