PigLayer.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import SoundMgr from "../base/SoundMgr";
  2. import Tool from "../base/Tool";
  3. var baseLayer = require('BaseLayer');
  4. cc.Class({
  5. extends: baseLayer,
  6. properties: {
  7. labVip: cc.RichText,
  8. labNum: cc.Label,
  9. labCun: cc.Label,
  10. labY: cc.Label,
  11. labCi: cc.Label,
  12. itemPre: cc.Node,
  13. conNode: cc.Node,
  14. acNode: cc.Node,
  15. ruleUI: cc.Node,
  16. ruleItemPre: cc.Node,
  17. ruleConNode: cc.Node,
  18. },
  19. // LIFE-CYCLE CALLBACKS:
  20. // onLoad () {},
  21. start () {
  22. this.labVip.string = `当前<color=#FFF33A>${'VIP12'}</color>储存上限`;
  23. this.labNum.string = '123123';
  24. this.labCun.string = 480;
  25. this.labY.string = `¥${12}`;
  26. this.labCi.string = `今日可购次数${21}`;
  27. this.acNode.getComponent('RechargeActivity').setType(3, this);
  28. this.initItems();
  29. this.initRuleItems();
  30. },
  31. initItems(){
  32. this.conNode.removeAllChildren();
  33. for(let i=0; i < 20; i++){
  34. let temp = cc.instantiate(this.itemPre);
  35. temp.setParent(this.conNode);
  36. temp.name = `${i}`;
  37. temp.active = true;
  38. temp.getChildByName('name').getComponent(cc.Label).string = '西门吹雪';
  39. temp.getChildByName('money').getComponent(cc.Label).string = 789;
  40. }
  41. },
  42. initRuleItems(){
  43. this.ruleConNode.removeAllChildren();
  44. for(let i=0; i < 11; i++){
  45. let temp = cc.instantiate(this.ruleItemPre);
  46. temp.setParent(this.ruleConNode);
  47. temp.name = `${i}`;
  48. temp.active = true;
  49. temp.getChildByName('labVip').getComponent(cc.Label).string = `VIP${i}`;
  50. temp.getChildByName('labCi').getComponent(cc.Label).string = `${21}次`;
  51. temp.getChildByName('labMax').getComponent(cc.Label).string = 778899;
  52. }
  53. },
  54. onClickYellow(){
  55. SoundMgr.playClick();
  56. },
  57. onClickRule(){
  58. SoundMgr.playClick();
  59. this.ruleUI.active = !this.ruleUI.active;
  60. },
  61. });