StoreDiamondDiscount.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. const WeChat = require('../net/WeChat');
  2. const GameModule = require("../utils/GameModule");
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. content: cc.Node,
  7. item: cc.Prefab,
  8. },
  9. // LIFE-CYCLE CALLBACKS:
  10. onLoad () {
  11. /// 初始化 四个
  12. let contentWidth = this.content.width;
  13. let itemWith = Math.floor((contentWidth - 75) / 2);
  14. for(let i = 0; i < 4; ++i) {
  15. let itemNode = cc.instantiate(this.item);
  16. itemNode.getComponent('StoreDiamondItem').init(i);
  17. let itemNodeWidth = itemNode.width;
  18. let itemNodeHeight = itemNode.height;
  19. let radio = itemNodeHeight / itemNodeWidth;
  20. itemNode.width = itemWith;
  21. itemNode.height = itemNodeHeight * radio;
  22. this.content.addChild(itemNode);
  23. }
  24. },
  25. init(index) {
  26. GameEvent.fire('StoreDiamondSelect', index);
  27. },
  28. start () {
  29. },
  30. /// 购买
  31. buyAction() {
  32. GameModule.audioMng.playClickButton();
  33. WeChat.jumpCustomerServices();
  34. },
  35. closeAction() {
  36. GameModule.audioMng.playClickButton();
  37. this.node.destroy();
  38. }
  39. // update (dt) {},
  40. });