StoreDiamondDiscount.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. start () {
  26. },
  27. /// 购买
  28. buyAction() {
  29. GameModule.audioMng.playClickButton();
  30. WeChat.jumpCustomerServices();
  31. },
  32. closeAction() {
  33. GameModule.audioMng.playClickButton();
  34. this.node.destroy();
  35. }
  36. // update (dt) {},
  37. });