UserInformationFigure.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. var DWTool = require('../utils/DWTool');
  2. const ArtistManager = require('../utils/ArtistManager');
  3. var { UserJobType } = require('../utils/GameEnum');
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. figure: sp.Skeleton, //人物形象
  8. decoration: sp.Skeleton, //人物配件动画
  9. },
  10. // LIFE-CYCLE CALLBACKS:
  11. onLoad () {
  12. this.node.on('touchend', () => {
  13. this.figure.setAnimation(0, 'click', false);
  14. this.figure.setCompleteListener(() => {
  15. this.figure.setAnimation(0, 'stand', true);
  16. });
  17. }, this);
  18. },
  19. start () {
  20. },
  21. onDisable() {
  22. this.node.active = false;
  23. this.decoration.node.active = false;
  24. },
  25. changeFigure(userInfo) {
  26. this.userInfo = userInfo;
  27. //现在只有舞者有骨骼动画,默认jodId为2
  28. ArtistManager.loadArtist(true, userInfo.gender, 2)
  29. .then((skeletonData) => {
  30. this.figure.skeletonData = skeletonData;
  31. this.figure.animation = "stand";
  32. this.node.active = true;
  33. // this.configDecoration();
  34. }).catch((err) => {
  35. console.log(err);
  36. });
  37. },
  38. configDecoration() {
  39. var filePath = '';
  40. var animation = '';
  41. if (this.userInfo.gender == 2 && this.userInfo.jobId == UserJobType.Dancer) {
  42. filePath = 'people_spines/wuzhe_huaban';
  43. animation = 'huaban';
  44. } else if (this.userInfo.gender != 2 && this.userInfo.jobId == UserJobType.Singer) {
  45. filePath = 'people_spines/geshou_yinfu';
  46. animation = 'yinfu';
  47. }
  48. cc.loader.loadRes(filePath, sp.SkeletonData, (err, skeletonData,) => {
  49. if (err) {
  50. } else {
  51. this.decoration.skeletonData = skeletonData;
  52. this.decoration.animation = animation;
  53. this.decoration.node.active = true;
  54. }
  55. });s
  56. },
  57. // update (dt) {},
  58. });