StarGiftBag.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. const GameModule = require('../utils/GameModule');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. scrollViewNode: cc.Node,
  6. giftLayout: cc.Layout,
  7. giftItem: cc.Prefab,
  8. emptyLabel: cc.Label
  9. },
  10. // LIFE-CYCLE CALLBACKS:
  11. // onLoad () {},
  12. start () {
  13. },
  14. init(array) {
  15. this.array = array;
  16. if (array.length > 0) {
  17. this.scrollViewNode.active = true;
  18. this.emptyLabel.node.active = false;
  19. for (let i = 0; i < array.length; ++i) {
  20. let gift = array[i];
  21. let item = cc.instantiate(this.giftItem);
  22. item = item.getComponent('StarGiftBagItem');
  23. item.configData(gift);
  24. this.giftLayout.node.addChild(item.node);
  25. }
  26. } else {
  27. this.scrollViewNode.active = false;
  28. this.emptyLabel.node.active = true;
  29. }
  30. },
  31. closeNode() {
  32. GameModule.audioMng.playClickButton();
  33. this.node.destroy();
  34. }
  35. // update (dt) {},
  36. });