123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import SoundMgr from "../base/SoundMgr";
- import ResMgr from "../base/ResMgr";
- import Tool from "../base/Tool";
- import UIMgr from "../base/UIMgr";
- var baseLayer = require('BaseLayer');
- cc.Class({
- extends: baseLayer,
- properties: {
- item1Pre: cc.Node,
- con1Node: cc.Node,
- lock3Node: cc.Node,
- item3Pre: cc.Node,
- scro3Node: cc.Node,
- con3Node: cc.Node,
- lab2Des: cc.Label,
- done2Node: cc.Node,
- buy2Node: cc.Node,
- go2Node: cc.Node,
- get2Node: cc.Node,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this._super();
- },
- start () {
- this.setCon1();
- this.setCon2();
- this.setCon3();
- },
- setCon1(){
- this.con1Node.removeAllChildren();
- for(let i=0; i < 3; i++){
- let temp = cc.instantiate(this.item1Pre);
- temp.setParent(this.con1Node);
- temp.y =0;
- console.log(temp.y);
- temp.name = `${i}`;
- temp.active = true;
- let labTitle = cc.find('kuang/labTitle', temp).getComponent(cc.Label);
- labTitle.string = `悬赏${998}元`;
- let sp = cc.find('kuang/sp', temp).getComponent(cc.Sprite);
- ResMgr.loadTexture('texture/PassBg/500', (spFrame)=>{
- sp.spriteFrame = spFrame;
- });
- let labDes = cc.find('kuang/labDes', temp).getComponent(cc.Label);
- labDes.string = `当日悬赏次数${0}/${10}`;
- let labCost = cc.find('layout/labCost', temp).getComponent(cc.Label);
- labCost.string = 123;
- let doneNode = temp.getChildByName('done');
- doneNode.active = false;
- let buyNode = temp.getChildByName('buy');
- buyNode.getChildByName('lab').getComponent(cc.Label).string = `VIP${i+1}可接取`;
- buyNode.active = true;
- Tool.addBtnListener(buyNode, this.node, 'ExchangeTaskLayer', 'onClickBuy1', {data: 'xxxx'});
- let goNode = temp.getChildByName('go');
- goNode.active = false;
- Tool.addBtnListener(goNode, this.node, 'ExchangeTaskLayer', 'onClickGo1', {data: 'go'});
- let getNode = temp.getChildByName('get');
- getNode.active = false;
- Tool.addBtnListener(getNode, this.node, 'ExchangeTaskLayer', 'onClickGet1', {data: 'get'});
- }
- },
- setCon2(){
- this.lab2Des.string = `悬赏1元`;
- this.done2Node.active = false;
- this.buy2Node.active = true;
- this.go2Node.active = false;
- this.get2Node.active = false;
- },
- setCon3(){
- this.lock3Node.active = false;
- this.scro3Node.active = true;
- this.con3Node.removeAllChildren();
- for(let i=0; i < 5; i++){
- let temp = cc.instantiate(this.item3Pre);
- temp.setParent(this.con3Node);
- temp.name = `${i}`;
- temp.active = true;
- let labTitle = cc.find('kuang/labTitle', temp).getComponent(cc.Label);
- labTitle.string = `悬赏${998}元`;
- let sp = cc.find('kuang/sp', temp).getComponent(cc.Sprite);
- ResMgr.loadTexture('texture/PassBg/500', (spFrame)=>{
- sp.spriteFrame = spFrame;
- });
- let labDes = cc.find('kuang/labDes', temp).getComponent(cc.Label);
- labDes.string = `当日悬赏次数${0}/${10}`;
- let labCost = cc.find('layout/labCost', temp).getComponent(cc.Label);
- labCost.string = 123;
- let doneNode = temp.getChildByName('done');
- doneNode.active = false;
- let buyNode = temp.getChildByName('buy');
- buyNode.active = true;
- Tool.addBtnListener(buyNode, this.node, 'ExchangeTaskLayer', 'onClickBuy3', {data: 'xxxx'});
- let goNode = temp.getChildByName('go');
- goNode.active = false;
- Tool.addBtnListener(goNode, this.node, 'ExchangeTaskLayer', 'onClickGo3', {data: 'go'});
- let getNode = temp.getChildByName('get');
- getNode.active = false;
- Tool.addBtnListener(getNode, this.node, 'ExchangeTaskLayer', 'onClickGet3', {data: 'get'});
- }
- },
-
- // click con1 start -------
- onClickBuy1(event, customEventData){
- SoundMgr.playClick();
- console.log('customEventData: ', customEventData);
- },
- onClickGo1(event, customEventData){
- SoundMgr.playClick();
- console.log('customEventData: ', customEventData);
- },
- onClickGet1(event, customEventData){
- SoundMgr.playClick();
- console.log('customEventData: ', customEventData);
- },
- // click con1 end ---------
- // click con2 start -------
- onClickBuy2(){
- SoundMgr.playClick();
- UIMgr.openUI('prefabs/SevenInvestLayer');
- },
- onClickGo2(){
- SoundMgr.playClick();
- },
- onClickGet2(){
- SoundMgr.playClick();
- },
- // click con2 end ---------
- // click con3 start -------
- onClickBuy3(event, customEventData){
- SoundMgr.playClick();
- console.log('customEventData: ', customEventData);
- },
- onClickGo3(event, customEventData){
- SoundMgr.playClick();
- console.log('customEventData: ', customEventData);
- },
- onClickGet3(event, customEventData){
- SoundMgr.playClick();
- console.log('customEventData: ', customEventData);
- },
- // click con3 end ---------
- });
|