cc.Class({
    extends: cc.Component,

    properties: {
        PlayerStatesNode: {
            default: null, 
            type: cc.Node, 
            serializable: true,
        },
    },
    onLoad () {
        this.PlayerStatesScp = this.PlayerStatesNode.getComponent('PlayerStates');
        this.anim = this.node.getComponent(sp.Skeleton);
        this.anim.setCompleteListener(this.SpineEventCallback);
    },
    Run(lv)
    {
        if(lv == this.PlayerStatesScp.state) return;

        this.PlayerStatesScp.state = lv;

        switch (lv) {
            case 1:
                //this.anim.animation = 'run';// 要播放的动画名称【必填】
                //this.anim.loop = true;// 是否循环
                this.runAnim = this.anim.setAnimation(0, 'Run1', true);
                break;
        
            case 2:
                //this.anim.animation = 'run';// 要播放的动画名称【必填】
                //this.anim.loop = true;// 是否循环
                this.runAnim = this.anim.setAnimation(0, 'Run2', true);
                break;

            case 3:
                //this.anim.animation = 'run';// 要播放的动画名称【必填】
                //this.anim.loop = true;// 是否循环
                this.runAnim = this.anim.setAnimation(0, 'Run3', true);
                break;
            default:
                break;
        }
    },
    Idel()
    {
        if(this.PlayerStatesScp.state == this.PlayerStatesScp.stateTag.idle) return;

        this.PlayerStatesScp.state = this.PlayerStatesScp.stateTag.idle;

        this.runAnim = this.anim.setAnimation(0, 'idle', true);
    },
    SpineEventCallback(trackEntry, loopCount)
    {
        if (trackEntry.animation.name === 'Run1') {
            //cc.log('Run1结束')
        }
    }
});
