12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- export default class LayerManager
- {
- /**
- * 添加内容到层
- * @param layerIndex
- * @param node
- */
- AddToLayer(layerIndex:number,node:fgui.GComponent):void{
- let layer:fgui.GComponent=this.GetLayer(layerIndex);
- if(layer==null){
- throw new Error("找不到:"+layerIndex+"层!");
- }
- layer.addChild(node);
- }
- /**
- * 从层上删除内容
- * @param layerIndex
- * @param node
- */
- RemoveFormeLayer(layerIndex:number,node:fgui.GComponent):void{
- let layer:fgui.GComponent=this.GetLayer(layerIndex);
- if(layer==null){
- throw new Error("找不到:"+layerIndex+"层!");
- }
- layer.removeChild(node);
- }
- /**
- * 通过层索引获取层
- * @param layerIndex
- */
- GetLayer(layerIndex:number):fgui.GComponent{
- let layer:fgui.GComponent=fgui.GRoot.inst.getChildAt(layerIndex).asCom;
- if(layer==null){
- throw new Error("找不到:"+layerIndex+"层!");
- }
- return layer;
- }
-
- /**
- * 单例
- */
- private static instance:LayerManager;
- public static get single():LayerManager{
- if(this.instance==null){
- this.instance=new LayerManager();
- }
- return this.instance;
- }
- }
|