123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- cc.Class({
- extends: cc.Component,
- properties: {
-
- },
- onLoad() {
- this.node.on("click", this._click, this)
- this.iconSprite = this.node.getComponent(cc.Sprite);
- // this.itemLabel_1 = this.node.children[0].children[0].getComponent(cc.Label);
- this.btn = this.node.getComponent(cc.Button);
- },
- init(src,id){
- this.id = id;
- this.src = src;
- //分平台展示
- if (id == 0 && AppConst.CHANNEL != AppConst.channel.QQMiniGame) {
- // 自动选中第一个
- this.src.selectedId = 1;
- this.node.active = false;
- let src = this.node.parent.children[1].getComponent("itemMoney");
- src.iconSprite.spriteFrame = this.src.iconSpriteFrame[1];
- return;
- }
- // TODO 新手判断
- if (id == 0) {
- if (window.newPlayer) {
- // 自动选中第零个
- this.src.selectedId = 0;
- this.node.active = true;
- this.iconSprite.spriteFrame = this.src.iconSpriteFrame[1];
- } else {
- // 自动选中第一个
- this.src.selectedId = 1;
- this.node.active = false;
- let src = this.node.parent.children[1].getComponent("itemMoney");
- src.iconSprite.spriteFrame = this.src.iconSpriteFrame[1];
- }
- }
- },
- _click(){
- this.src.selectedId = this.id;
- let parent = this.node.parent;
- for (let i = 0; i < parent.childrenCount; i++) {
- let itemMoney = parent.children[i].getComponent("itemMoney");
- if(i == this.id){
- itemMoney.iconSprite.spriteFrame = this.src.iconSpriteFrame[1];
- }else{
- itemMoney.iconSprite.spriteFrame = this.src.iconSpriteFrame[0];
- }
- }
- }
- // update (dt) {},
- });
|