import SoundMgr from "../base/SoundMgr"; import Tool from "../base/Tool"; cc.Class({ extends: cc.Component, properties: { labDayLive: cc.Label, dayNodes: [cc.Node], spDayBar: cc.Sprite, labWeekLive: cc.Label, weekNodes: [cc.Node], spWeekBar: cc.Sprite, logoSpArr: [cc.SpriteFrame], propSpArr: [cc.SpriteFrame], itemPrefab: cc.Node, conNode: cc.Node, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start () { }, initData(index){ this.type = index; //日 for(let i=0; i< this.dayNodes.length; i++){ this.dayNodes[i].getChildByName('done').active = false; this.dayNodes[i].getChildByName('num').getComponent(cc.Label).string = '2'; } this.labDayLive.string = 128; this.spDayBar.fillRange = 0.8; //周 for(let i=0; i < this.weekNodes.length; i++){ this.weekNodes[i].getChildByName('done').active = false; this.weekNodes[i].getChildByName('num').getComponent(cc.Label).string = '8'; } this.labWeekLive.string = 999; this.spWeekBar.fillRange = 0.3; //con this.data = [17,18,19,110,111,112]; if(this.type == 1){ this.data = [9,10]; } this.conNode.removeAllChildren(); for(let i=0; i < this.data.length; i++){ let temp = cc.instantiate(this.itemPrefab); temp.setParent(this.conNode); temp.name = `${i}`; temp.active = true; temp.data = this.data[i]; this.setItems(temp); } }, setItems(tNode){ tNode.getChildByName('logosp').getComponent(cc.Sprite).spriteFrame = this.logoSpArr[1]; tNode.getChildByName('name').getComponent(cc.Label).string = '精英计划'; tNode.getChildByName('bar').getComponent(cc.Sprite).fillRange = 0.8; tNode.getChildByName('labPro').getComponent(cc.Label).string = `${1}/${2}`; tNode.getChildByName('labCoin').getComponent(cc.Label).string = `x${3453}`; tNode.getChildByName('labAc').getComponent(cc.Label).string = `x${12}`; let gonode = tNode.getChildByName('go'); gonode.active = false; Tool.addBtnListener(gonode, this.node, 'TaskPage2', 'onClickGo', tNode.data); let getnode = tNode.getChildByName('get'); getnode.active = true; Tool.addBtnListener(getnode, this.node, 'TaskPage2', 'onClickGet', tNode.data); }, onClickGo(event, customEventData){ SoundMgr.playClick(); console.log('go: ', customEventData); }, onClickGet(event, customEventData){ SoundMgr.playClick(); console.log('get: ', customEventData); }, onClickDayGift(event, index){ SoundMgr.playClick(); console.log('day: ', index); }, onClickWeekGift(event, index){ SoundMgr.playClick(); console.log('week: ', index); }, });