Przeglądaj źródła

【修复】引导弹出时其他界面没有关闭
http://chandao.zbc6b.com/zentao/bug-view-1017.html###

zouyong 5 lat temu
rodzic
commit
39cbeb6284

+ 1 - 0
assets/script/game/game/Game.ts

@@ -177,6 +177,7 @@ export default class Game extends cc.Component {
         gData.gameData.init_red_point = false;
         gData.gameData.init_red_point = false;
 
 
         if (this.nodeRedPoint.node_redbagCash.active) {
         if (this.nodeRedPoint.node_redbagCash.active) {
+            mk.ui.closeAllUI(["game","guide"])
             mk.guide.open(2);
             mk.guide.open(2);
         }
         }
     }
     }

+ 25 - 3
assets/script/mk/system/UISystem.ts

@@ -63,10 +63,10 @@ export default class UISystem extends cc.Component {
                         return;
                         return;
                     }
                     }
 
 
-                    if(parent){
+                    if (parent) {
                         node_panel.parent = parent;
                         node_panel.parent = parent;
                     }
                     }
-                    else{
+                    else {
                         self.panelParent.addChild(node_panel);
                         self.panelParent.addChild(node_panel);
                     }
                     }
 
 
@@ -130,12 +130,34 @@ export default class UISystem extends cc.Component {
         mk.event.emit('close-panel', panelName);
         mk.event.emit('close-panel', panelName);
     }
     }
 
 
-    private destroyNode(node_panel, panelName, callBack) {
+    private destroyNode(node_panel, panelName, callBack = null) {
         node_panel.destroy();
         node_panel.destroy();
         delete this.curOnPanelDic[panelName];
         delete this.curOnPanelDic[panelName];
         this.isPanelClosing = false;
         this.isPanelClosing = false;
         callBack && callBack();
         callBack && callBack();
     }
     }
+
+    /**
+     * 关闭所有界面,除了主界面
+     * @param except 排除的ui
+     */
+    closeAllUI(except: string[] = null) {
+        for (let panelName in this.curOnPanelDic) {
+            if (except && except.length > 0 && except.indexOf(panelName) != -1) {
+                continue;
+            }
+            let node_panel = this.getCurOnPanel(panelName);
+            let comp_anim = node_panel.getComponent('EffectOpenAndClose');
+            if (comp_anim) {
+                comp_anim.hideEffect(this.destroyNode.bind(this, node_panel, panelName));
+            } else {
+                this.destroyNode(node_panel, panelName);
+            }
+            mk.event.emit('close-panel', panelName);
+        }
+
+        this.isPanelClosing = true;
+    }
 }
 }
 
 
 /** 界面打开操作 */
 /** 界面打开操作 */