Просмотр исходного кода

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

zouyong 5 лет назад
Родитель
Сommit
39cbeb6284
2 измененных файлов с 26 добавлено и 3 удалено
  1. 1 0
      assets/script/game/game/Game.ts
  2. 25 3
      assets/script/mk/system/UISystem.ts

+ 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;
 
         if (this.nodeRedPoint.node_redbagCash.active) {
+            mk.ui.closeAllUI(["game","guide"])
             mk.guide.open(2);
         }
     }

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

@@ -63,10 +63,10 @@ export default class UISystem extends cc.Component {
                         return;
                     }
 
-                    if(parent){
+                    if (parent) {
                         node_panel.parent = parent;
                     }
-                    else{
+                    else {
                         self.panelParent.addChild(node_panel);
                     }
 
@@ -130,12 +130,34 @@ export default class UISystem extends cc.Component {
         mk.event.emit('close-panel', panelName);
     }
 
-    private destroyNode(node_panel, panelName, callBack) {
+    private destroyNode(node_panel, panelName, callBack = null) {
         node_panel.destroy();
         delete this.curOnPanelDic[panelName];
         this.isPanelClosing = false;
         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;
+    }
 }
 
 /** 界面打开操作 */