var DWTool = require('../utils/DWTool');

cc.Class({
    extends: cc.Component,

    properties: {
        figure: sp.Skeleton,  //人物形象
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.node.on('touchend', () => {
            this.figure.setAnimation(0, 'click', false);
            this.figure.setCompleteListener(() => {
                this.figure.setAnimation(0, 'stand', true);
            });
        }, this);
    },

    start () {

    },

    onDisable() {
        this.node.active = false;
    },

    changeFigure(userInfo) {
        var url = 'spines/wuzhe_v';
        if (userInfo.gender == 1) {
            url = 'spines/wuzhe_m';
        }

        cc.loader.loadRes(url, sp.SkeletonData, (error, result) => {
            if (error === null) {
                this.figure.skeletonData = result;
                this.figure.animation = "stand";
                this.node.active = true;
            } else {
                console.log(JSON.stringify(error));
            }
        });
    },

    // update (dt) {},
});
