6
0

2 Incheckningar 0e7f8a5017 ... 4444286a4d

Upphovsman SHA1 Meddelande Datum
  SunnyLinSD 4444286a4d Merge branch '0.6' of http://svn.ouj.com:3000/DWG/allstar into 0.6 6 år sedan
  SunnyLinSD 5f59873b4d 修改道具显示逻辑 6 år sedan

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

@@ -285,7 +285,7 @@ cc.Class({
 
                 if (buildingItems.hasOwnProperty(buildingId)) {
                     let prop = buildingItems[buildingId];
-                    itemScript.configProp(prop);
+                    itemScript.showProp(prop, false);
                 }
             }
         })

+ 24 - 5
assets/scripts/levelHome/LevelHomeItem.js

@@ -242,6 +242,9 @@ cc.Class({
         // 配置界面上的金币
         this.configCoins();
 
+        // 配置界面上的道具
+        this.configProp();
+
     },
 
     onDestroy() {
@@ -379,11 +382,21 @@ cc.Class({
         }
     },
 
-    configProp(propData) {
+    configProp() {
+
+        let propNode = cc.instantiate(this.propPrefab)
+        this.propScript = propNode.getComponent('LevelHomePropItem')
+        this.propWrap.addChild(propNode);  
+        this.propScript.node.position = cc.v2(150, -108);
+        this.propScript.node.active = false;
+        this.propScript.isPlay = false;
+        this.propScript.isPlaying = false;
+        this.propWrap.addChild(propNode);
+    },
+
+    showProp(propData, isPlayAnimation=true) {
 
         if (!this.isHasProp) {
-            let propNode = cc.instantiate(this.propPrefab)
-            this.propScript = propNode.getComponent('LevelHomePropItem')
             this.isHasProp = true;
             this.propScript.init(this.buildingInfo.buildingId, propData, (showFrame, showText) => {
                 this.propScript = null;
@@ -391,9 +404,15 @@ cc.Class({
                 // 显示领取动画
                 this.parent.showActGift(showFrame, showText)
             });
-            this.propWrap.addChild(propNode);
+            if (isPlayAnimation) {
+                this.propScript.showAnimation();
+            } else {
+                this.propScript.node.position = cc.v2(150, -28);
+            }
+            
         } else {
-            this.propScript.updateProp(propData)
+            this.propScript.updateProp(propData);
+            this.propScript.updateAnimation();
         }
     },
 

+ 4 - 3
assets/scripts/levelHome/LevelHomePropItem.js

@@ -42,17 +42,18 @@ cc.Class({
     // LIFE-CYCLE CALLBACKS:
     onLoad () {
 
-        this.node.y = -26;
-        this.node.x = 150;
+        // this.node.y = -26;
+        // this.node.x = 150;
 
         this.node.on(cc.Node.EventType.TOUCH_END, _.debounce(() => {
             HomeApi.itemCollect(this.buildingId, () => {
 
+                this.pickupCallback();
                 let showFrame = this.propSprite.spriteFrame;
                 let showText = `${this.propData.name} x ${this.propData.count}`
                 this.pickupCallback(showFrame, showText);
-                
                 this.node.destroy();
+                
             }, (err) => {
                 console.log(err);
             })