1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import SoundMgr from "../base/SoundMgr";
- import Tool from "../base/Tool";
- cc.Class({
- extends: cc.Component,
- properties: {
- logoSpArr: [cc.SpriteFrame],
- propSpArr: [cc.SpriteFrame],
- itemPrefab: cc.Node,
- conNode: cc.Node,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {},
- start () {
- },
- initData(index){
- this.type = index;
- this.data = [1,2,3,4,5,6, 7,8,9,10, 11];
- if(this.type == 0){
- this.data = [1,2];
- }
- 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[0];
- tnode.getChildByName('name').getComponent(cc.Label).string = '飓风行动';
- tnode.getChildByName('bar').getComponent(cc.Sprite).fillRange = 0.5;
- tnode.getChildByName('labPro').getComponent(cc.Label).string = `${3}/${4}`;
- tnode.getChildByName('rewardsp').getComponent(cc.Sprite).spriteFrame = this.propSpArr[0];
- tnode.getChildByName('labAmount').getComponent(cc.Label).string = `x${20}`;
- let gonode = tnode.getChildByName('go');
- gonode.active = true;
- Tool.addBtnListener(gonode, this.node, 'TaskPage1', 'onClickGo', tnode.data);
- let getnode = tnode.getChildByName('get');
- getnode.active = false;
- Tool.addBtnListener(getnode, this.node, 'TaskPage1', 'onClickGet', tnode.data);
- },
- onClickGo(event, customEventData){
- SoundMgr.playClick();
- console.log('go: ', customEventData);
- },
- onClickGet(event, customEventData){
- SoundMgr.playClick();
- console.log('get: ', customEventData);
- },
- });
|