BattleMain.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. const ButtonSelect1 = require('ButtonSelect1')
  2. const ViewBase = require('ViewBase');
  3. const SequenCreateView = require('SequenCreateView');
  4. const BoxItem = require('BoxItem')
  5. cc.Class({
  6. extends: ViewBase,
  7. properties: {
  8. button1: {
  9. default: null,
  10. type: ButtonSelect1,
  11. serializable: true,
  12. },
  13. button2: {
  14. default: null,
  15. type: ButtonSelect1,
  16. serializable: true,
  17. },
  18. button3: {
  19. default: null,
  20. type: ButtonSelect1,
  21. serializable: true,
  22. },
  23. buttonPrice1: {
  24. default: null,
  25. type: ButtonSelect1,
  26. serializable: true,
  27. },
  28. buttonPrice2: {
  29. default: null,
  30. type: ButtonSelect1,
  31. serializable: true,
  32. },
  33. buttonPrice3: {
  34. default: null,
  35. type: ButtonSelect1,
  36. serializable: true,
  37. },
  38. buttonPrice4: {
  39. default: null,
  40. type: ButtonSelect1,
  41. serializable: true,
  42. },
  43. scrollViewBox: {
  44. default: null,
  45. type: cc.ScrollView,
  46. serializable: true,
  47. },
  48. viewContent: {
  49. default: null,
  50. type: cc.Node,
  51. serializable: true,
  52. }
  53. },
  54. onLoad () {
  55. this.buttons = [
  56. this.button1,
  57. this.button2,
  58. this.button3,
  59. ];
  60. this.buttonPrices = [
  61. this.buttonPrice1,
  62. this.buttonPrice2,
  63. this.buttonPrice3,
  64. this.buttonPrice4,
  65. ];
  66. this.sequenCreateBoxs = new SequenCreateView().initRoot(this);
  67. this.initBoxs();
  68. this.onClickPrice(null, "0");
  69. },
  70. initBoxs() {
  71. // getConfigAll
  72. // this.sequenCreateBoxs.addDatas(G.CfgMgr.battleBoxConfig.getConfigAll());
  73. this.sequenCreateBoxs.addDatas(G.CfgMgr.battleBoxConfig.getConfigAll());
  74. this.sequenCreateBoxs.startCreate(JMC.UIEnum.BoxItem, this.scrollViewBox.content, function(node, data) {
  75. let boxItem = node.getComponent(BoxItem);
  76. boxItem.setScale(0.73);
  77. boxItem.setNameScale(1/0.73);
  78. boxItem.setName(data.name);
  79. boxItem.setPrice(G.PlayUtils.getPrice(data.price));
  80. });
  81. },
  82. updatePriceSelect(index) {
  83. for (let i = 0; i < this.buttonPrices.length; i++) {
  84. const b = this.buttonPrices[i];
  85. b.setSelect(index == i)
  86. }
  87. },
  88. onClickTitle(event, customEventData) {
  89. let index = parseInt(customEventData)
  90. },
  91. onClickPrice(event, customEventData) {
  92. let index = parseInt(customEventData)
  93. this.updatePriceSelect(index)
  94. },
  95. // update (dt) {},
  96. });