BonusRankLayer.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import ResMgr from "../base/ResMgr";
  2. import SoundMgr from "../base/SoundMgr";
  3. import Tool from "../base/Tool";
  4. import UserInfoMgr from "../base/user/UserInfoMgr";
  5. var baseLayer = require('BaseLayer');
  6. cc.Class({
  7. extends: baseLayer,
  8. properties: {
  9. atlasVIP: cc.SpriteAtlas, //vip图集
  10. numsNode: [cc.Node],
  11. labTime: cc.Label,
  12. topThreeNode: [cc.Node],
  13. myNoRank: cc.Node,
  14. myRank: cc.Node,
  15. topsNode: [cc.Node],
  16. labMyRank: cc.Label,
  17. labMyGua: cc.Label,
  18. labMyBli: cc.Label,
  19. spMyHead: cc.Sprite,
  20. spVipDi: cc.Sprite,
  21. spVip: cc.Sprite,
  22. labMyName: cc.Label,
  23. labMyCount: cc.Label,
  24. itemPre: cc.Node,
  25. conNode: cc.Node,
  26. },
  27. // LIFE-CYCLE CALLBACKS:
  28. onLoad () {
  29. this._super();
  30. this.poolNum = 343512; //奖池数字
  31. this.lerpTime = 13123123;
  32. },
  33. start () {
  34. this.setNums();
  35. this.daojishi();
  36. this.schedule(this.daojishi, 1, cc.macro.REPEAT_FOREVER);
  37. this.topThree();
  38. this.setCon();
  39. this.setMy();
  40. },
  41. //设置奖池
  42. setNums(){
  43. let pLength = this.poolNum.toString().length;
  44. if(pLength > this.numsNode.length){
  45. console.log('位数超了');
  46. return;
  47. }
  48. let splitNum = this.poolNum.toString().split('');
  49. splitNum.reverse();
  50. for(let i= this.numsNode.length-1; i > 0; i--){
  51. this.numsNode[i].getComponent(cc.Label).string = 0;
  52. if(splitNum[ (this.numsNode.length-1) - i]){
  53. this.numsNode[i].getComponent(cc.Label).string = splitNum[ (this.numsNode.length-1) - i];
  54. }
  55. }
  56. },
  57. daojishi(){
  58. if(this.lerpTime <= 1){
  59. this.unschedule(this.daoshiji);
  60. return;
  61. }
  62. this.lerpTime -= 1;
  63. this.labTime.string = Tool.timesBySec(this.lerpTime);
  64. },
  65. topThree(){
  66. for(let tNode of this.topThreeNode){
  67. tNode.getChildByName('labName').getComponent(cc.Label).string = '叶孤城';
  68. let spHead = cc.find('mask/head', tNode).getComponent(cc.Sprite);
  69. // ResMgr.loadRemoteTexture('xxx', (spFrame)=>{
  70. // spHead.spriteFrame = spFrame;
  71. // });
  72. let labBli = cc.find('di3/labBli', tNode).getComponent(cc.Label);
  73. labBli.string = 1288;
  74. tNode.getChildByName('labGua').getComponent(cc.Label).string = `瓜分: ${19.99}%`;
  75. tNode.getChildByName('labCount').getComponent(cc.Label).string = 550055;
  76. }
  77. },
  78. setCon(){
  79. this.conNode.removeAllChildren();
  80. for(let i=0; i < 15; i++){
  81. let temp = cc.instantiate(this.itemPre);
  82. temp.setParent(this.conNode);
  83. temp.name = `${i}`;
  84. temp.active = true;
  85. temp.getChildByName('labR').getComponent(cc.Label).string = 17;
  86. let sp = cc.find('mask/sp', temp).getComponent(cc.Sprite);
  87. ResMgr.loadTexture('texture/head/h1', (spFrame)=>{
  88. sp.spriteFrame = spFrame;
  89. });
  90. temp.getChildByName('spVipDi').getComponent(cc.Sprite).spriteFrame = this.atlasVIP.getSpriteFrame('VIPdi1');
  91. temp.getChildByName('spVIP').getComponent(cc.Sprite).spriteFrame = this.atlasVIP.getSpriteFrame('VIP1');
  92. temp.getChildByName('labName').getComponent(cc.Label).string = '陆小凤';
  93. temp.getChildByName('labCount').getComponent(cc.Label).string = 9998;
  94. temp.getChildByName('labGua').getComponent(cc.Label).string = `瓜分: ${87.12}%`;
  95. temp.getChildByName('labBli').getComponent(cc.Label).string = 8999;
  96. }
  97. },
  98. setMy(){
  99. this.myNoRank.active = false;
  100. this.myRank.active = true;
  101. if(this.myRank.active){
  102. for(let i=0; i < this.topsNode.length; i++){
  103. this.topsNode[i].active = false;
  104. }
  105. this.labMyRank.string = 12;
  106. this.labMyGua.string = `瓜分: ${12.12}%`;
  107. this.labMyBli.string = 778811;
  108. }
  109. ResMgr.loadTexture('texture/head/h1', (sp)=>{
  110. this.spMyHead.spriteFrame = sp;
  111. this.spMyHead.node.width = 90;
  112. this.spMyHead.node.height = 90;
  113. });
  114. this.spVipDi.spriteFrame = this.atlasVIP.getSpriteFrame('VIPdi1');
  115. this.spVip.spriteFrame = this.atlasVIP.getSpriteFrame('VIP1');
  116. this.labMyName.string = UserInfoMgr.getUserName();
  117. this.labMyCount.string = '998';
  118. },
  119. });