123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import SoundMgr from "../base/SoundMgr";
- import Tool from "../base/Tool";
- cc.Class({
- extends: cc.Component,
- properties: {
- atlasCoin: cc.SpriteAtlas, //金币图集
- itemPrefab: cc.Node,
- conNode: cc.Node,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.initItems();
- },
- start () {
- },
- showShop(hallSceneJs){
- this.hallSceneJs = hallSceneJs;
- this.node.active = true;
- },
- initItems(){
- this.conNode.removeAllChildren();
- for(let i=0; i < 6; i++){
- let temp = cc.instantiate(this.itemPrefab);
- temp.setParent(this.conNode);
- temp.name = `item${i}`;
- temp.active = true;
- temp.getChildByName('labBuy').getComponent(cc.Label).string = '111';
- temp.getChildByName('icon').getComponent(cc.Sprite).spriteFrame = this.atlasCoin.getSpriteFrame('coin2');
- temp.getChildByName('labGive').getComponent(cc.Label).string = `+${22}万`;
- cc.find('btn_yellow/labY', temp).getComponent(cc.Label).string = `¥${60}`;
- let xx = temp.getChildByName('btn_yellow');
- Tool.addBtnListener(xx, this.node, 'ShopLayer', 'onClickY', i);
- }
- },
- onClickY(event, customEventData){
- console.log('customEventData: ', customEventData);
- },
- onClose(){
- SoundMgr.playClick();
- this.node.active = false;
- this.hallSceneJs.showHides(true);
- },
- });
|