import MainGameView from "./MainGameView"; import InGameView from "./InGameView"; export enum ViewType{MainView,IngameView}; export interface SC{ Show(); Close(); } export class ViewManager{ private static ins:ViewManager; public showexportview:number = 0; private popViewDic:[any][any] = []; public ViewSprite:Laya.Sprite = new Laya.Sprite(); public OtherViewSprite:Laya.Sprite = new Laya.Sprite(); public curView:any; constructor(){ ViewManager.ins = this; Laya.stage.addChild(this.ViewSprite); Laya.stage.addChild(this.OtherViewSprite); } public static get Instance():ViewManager{ if(ViewManager.ins){ return ViewManager.ins } else{ return new ViewManager(); } } ShowView(_viewtype:ViewType,data = null){ if(this.curView != null){ this.curView.Close(); this.curView.destroy(); this.curView.removeSelf(); } // GuangGao.Clear(); this.curView = this.CreateView(_viewtype); this.curView.name = ViewType[_viewtype]; this.ViewSprite.addChild(this.curView); this.curView.Show(data); } CloseView(){ if(this.curView != null){ this.curView.Close(); this.curView.destroy(); this.curView.removeSelf(); } } //全屏导出页 public OpenPopView(viewType:ViewType,data:any = null) { // GuangGao.Clear(); var popView; if(this.popViewDic[viewType]) { popView = this.popViewDic[viewType]; this.OtherViewSprite.setChildIndex(popView,this.OtherViewSprite.numChildren - 1); popView.visible = true; } else { popView = this.CreateView(viewType); this.OtherViewSprite.addChild(popView); this.popViewDic[viewType] = popView; } this.showexportview = 1; popView.OnOpen(data); } public ClosePopView(viewType:ViewType) { var popView = this.popViewDic[viewType]; if(popView == null){ return; } // GuangGao.Clear(); popView.OnHide(); popView.visible = false; this.showexportview = 0; } ClearPopViews() { // GuangGao.Clear(); } CreateView(_viewtype:ViewType){ switch (_viewtype) { case ViewType.MainView: return new MainGameView(); case ViewType.IngameView: return new InGameView(); } return null; } }