Ver código fonte

修复tab栏报错以及levelhome报错, 优化道具显示逻辑

SunnyLinSD 6 anos atrás
pai
commit
53541602ae

+ 1 - 5
assets/scripts/Tab.js

@@ -193,12 +193,8 @@ cc.Class({
         for (let child of this.friendScrollView.content.children) {
             child.destroy();
         }
-        
-        // 默认有全部好友和邀请两个节点
-        let count = 1;
-        count += this.friends.length;
 
-        for (let i = 0; i < count; i++) {
+        for (let i = 0; i < this.friends.length; i++) {
             let item = cc.instantiate(this.friendItem);
 
             let scriptComponent = item.getComponent('LevelHomeFriendItem');

+ 6 - 5
assets/scripts/levelHome/LevelHome.js

@@ -271,11 +271,12 @@ cc.Class({
                 
                 let itemScript;
                 let filterList = this.buildings.filter( item => item.buildingInfo.buildingId === parseInt(buildingId) ) || [];
-                if (filterList.length > 0) { itemScript = filterList[0]; }
-
-                if (buildingItems.hasOwnProperty(buildingId)) {
-                    let prop = buildingItems[buildingId];
-                    itemScript.showProp(prop, false);
+                if (filterList.length > 0) { 
+                    itemScript = filterList[0]; 
+                    if (buildingItems.hasOwnProperty(buildingId)) {
+                        let prop = buildingItems[buildingId];
+                        itemScript.showProp(prop, false);
+                    }
                 }
             }
         })

+ 7 - 3
assets/scripts/levelHome/LevelHomeItem.js

@@ -396,6 +396,11 @@ cc.Class({
         let propNode = cc.instantiate(this.propPrefab)
         this.propScript = propNode.getComponent('LevelHomePropItem')
         this.propWrap.addChild(propNode);  
+        this.hideProp();
+    },
+
+    hideProp() {
+        this.isHasProp = false; 
         this.propScript.node.position = cc.v2(150, -108);
         this.propScript.node.active = false;
         this.propScript.isPlay = false;
@@ -407,12 +412,10 @@ cc.Class({
         if (!this.isHasProp) {
             this.isHasProp = true;
             this.propScript.init(this.buildingInfo.buildingId, propData, (showFrame, showText) => {
-                this.isHasProp = false; 
                 // 显示领取动画
                 this.parent.showActGift(showFrame, showText)
 
-                this.propScript.node.active = false;
-                this.propScript.node.position = cc.v2(150, -108);
+                this.hideProp();
             });
             if (isPlayAnimation) {
                 this.propScript.showAnimation();
@@ -676,6 +679,7 @@ cc.Class({
                 this.totalRate = 0;
                 this.lockNode.active = true;
                 this.costLabel.string = 0;
+                this.hideProp();
 
                 this.unLockBuildName.string = `<b><color=#ffffff>${buildingInfo.name}</c></b>`;
                 this.unlockRichText.string = `<img src='alert_coin'/><b><color=#ffffff> ${DWTool.coinParse(buildingInfo.unlockScore)}</c><b/>`;

+ 1 - 1
assets/scripts/levelHome/LevelHomePropItem.js

@@ -131,6 +131,6 @@ cc.Class({
         let callback = cc.callFunc(() => {
             this.isPlaying = false;
         });
-        this.coinNode.runAction(cc.sequence(upAction, downAction, callback));
+        this.propSprite.node.runAction(cc.sequence(upAction, downAction, callback));
     },
 });