GetRewardLayer.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var baseLayer = require('BaseLayer');
  2. import SoundMgr from "../base/SoundMgr";
  3. cc.Class({
  4. extends: baseLayer,
  5. properties: {
  6. spArr: [cc.SpriteFrame],
  7. itemPrefab: cc.Node,
  8. layoutNode: cc.Node,
  9. },
  10. // LIFE-CYCLE CALLBACKS:
  11. onLoad () {
  12. this._super(true);
  13. },
  14. start () {
  15. },
  16. initData(){
  17. this.scheduleOnce(this.onClose, 3);
  18. this.layoutNode.removeAllChildren();
  19. for(let i=0; i < 3; i++){
  20. let temp = cc.instantiate(this.itemPrefab);
  21. temp.setParent(this.layoutNode);
  22. temp.active = true;
  23. temp.getChildByName('labName').getComponent(cc.Label).string = 'xx';
  24. temp.getChildByName('sp').getComponent(cc.Sprite).spriteFrame = this.spArr[0];
  25. temp.getChildByName('labNum').getComponent(cc.Label).string = `x${200}`;
  26. }
  27. },
  28. onClose(){
  29. SoundMgr.playClick();
  30. this.unscheduleAllCallbacks();
  31. this._super();
  32. },
  33. // update (dt) {},
  34. });