var DWTool = require('../utils/DWTool'); const ArtistManager = require('../utils/ArtistManager'); var { UserJobType } = require('../utils/GameEnum'); cc.Class({ extends: cc.Component, properties: { figure: sp.Skeleton, //人物形象 decoration: 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; this.decoration.node.active = false; }, changeFigure(userInfo) { this.userInfo = userInfo; //现在只有舞者有骨骼动画,默认jodId为2 ArtistManager.loadArtist(true, userInfo.gender, 2) .then((skeletonData) => { this.figure.skeletonData = skeletonData; this.figure.animation = "stand"; this.node.active = true; // this.configDecoration(); }).catch((err) => { console.log(err); }); }, configDecoration() { var filePath = ''; var animation = ''; if (this.userInfo.gender == 2 && this.userInfo.jobId == UserJobType.Dancer) { filePath = 'people_spines/wuzhe_huaban'; animation = 'huaban'; } else if (this.userInfo.gender != 2 && this.userInfo.jobId == UserJobType.Singer) { filePath = 'people_spines/geshou_yinfu'; animation = 'yinfu'; } cc.loader.loadRes(filePath, sp.SkeletonData, (err, skeletonData,) => { if (err) { } else { this.decoration.skeletonData = skeletonData; this.decoration.animation = animation; this.decoration.node.active = true; } });s }, // update (dt) {}, });