ArtistManager.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. const DWTool = require("./DWTool");
  2. class ThemeManager {
  3. /**
  4. * 从res中加载对应的艺人骨骼动画
  5. * @param {*} isBigMan
  6. * @param {*} gender
  7. * @param {*} jobId 1: 主持, 2: 舞者, 3: 歌手, 4: 演员, 5: 电竞明星
  8. */
  9. static loadArtist(isBigMan = false, gender = 1, jobId) {
  10. //处理性别为0时未知性别
  11. if (gender === 0) {
  12. gender = 1;
  13. }
  14. let p = new Promise((resolve, reject) => {
  15. let name = `4${isBigMan ? 1 : 2}${gender}0${jobId}`;
  16. cc.loader.loadRes(`./people_spines/${name}`, sp.SkeletonData, (err, skeletonData,) => {
  17. if (err) {
  18. reject(err);
  19. } else {
  20. resolve(skeletonData);
  21. }
  22. });
  23. });
  24. return p;
  25. }
  26. static loadStar(starId) {
  27. // starId = starId > 3 ? (Math.ceil(Math.random()*3)) : starId;
  28. let p = new Promise((resolve, reject) => {
  29. let name = 60000 + parseInt(starId);
  30. cc.loader.loadRes(`./spines/star/${name}`, sp.SkeletonData, (err, skeletonData,) => {
  31. if (err) {
  32. reject(err);
  33. } else {
  34. resolve(skeletonData);
  35. }
  36. });
  37. });
  38. return p;
  39. }
  40. //因骨骼动画未全部完成,顾加入静态职业人物
  41. static loadArtistImage(gender = 1, jobId) {
  42. //处理性别为0时未知性别
  43. if (gender === 0) {
  44. gender = 1;
  45. }
  46. let p = new Promise((resolve, reject) => {
  47. let name = `41${gender}0${jobId}`;
  48. cc.loader.loadRes(`people_figure/${name}`, cc.SpriteFrame, (err, spriteFrame) => {
  49. if (err) {
  50. reject(err);
  51. } else {
  52. resolve(spriteFrame);
  53. }
  54. });
  55. });
  56. return p;
  57. }
  58. }
  59. module.exports = ThemeManager;