import { _decorator, Component, Node, Skeleton, sp, resources, find, Layers } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('NewComponent')
export class NewComponent extends Component {
    @property(sp.Skeleton)
    skeleton: sp.Skeleton = null;
    start() {

    }

    testFunc() {
        this.skeleton.node.active = false;
        
        resources.load('spine/alien/alien-pro', sp.SkeletonData, (err, data) => {
            // spine加载完成后
            // let node = new Node('test');
            // node.layer = Layers.Enum.UI_2D;
            // let com = node.addComponent(sp.Skeleton);
            // find('Canvas').addChild(node);
            // com.skeletonData = data;
            // com.setAnimation(0,'run',true);
            this.skeleton.node.active = true;
            this.skeleton.skeletonData = data;
            this.skeleton.setAnimation(0,'run',true);
        })
    }

    testFunc2() {
        // find('Canvas/test').destroy();
        this.skeleton.skeletonData = null;

        this.skeleton.node.active = false;

    }
    update(deltaTime: number) {

    }
}

