1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import SoundMgr from "../base/SoundMgr";
- import Tool from "../base/Tool";
- var baseLayer = require('BaseLayer');
- cc.Class({
- extends: baseLayer,
- properties: {
- atlasCoin: cc.SpriteAtlas, //金币图集
- itemPrefab: cc.Node,
- conNode: cc.Node,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this._super();
- this.initItems();
- },
- start () {
- },
- initItems(){
- this.conNode.removeAllChildren();
- for(let i=0; i< 7; i++){
- let temp = cc.instantiate(this.itemPrefab);
- temp.setParent(this.conNode);
- temp.name = `${i}`;
- temp.active = true;
- temp.getChildByName('labCoin').getComponent(cc.Label).string = `${321}万金币`;
- temp.getChildByName('sp').getComponent(cc.Sprite).spriteFrame = this.atlasCoin.getSpriteFrame('coin2');
- temp.getChildByName('labCi').getComponent(cc.Label).string = `今日剩余兑换${12}次`;
- let labNum = cc.find('layout/labNum', temp).getComponent(cc.Label);
- labNum.string = `x${333}`;
- let labVip = cc.find('btn_orange/labVip', temp).getComponent(cc.Label);
- labVip.string = `VIP${3}可兑换`;
- let dui = temp.getChildByName('btn_orange');
- Tool.addBtnListener(dui, this.node, 'Exchange2Layer', 'onClickExchange', i);
- }
- },
- onClickExchange(event, customEventData){
- SoundMgr.playClick();
- console.log('customEventData: ', customEventData);
- },
- });
|