做新手引导层级放在最上层。这个是我添加的。还有好多地方需要注意的东西
//
//created by zhengxin at 2016-05-17
//Stage的rootContainer为Main DisplayObjectContainer对象,见Main.ts
//把游戏分为3个主要场景Scene:LoginFrame、MainFrame、BattleFrame,还可以有其他类型BattleFrame
//StartStoryFrame开场动画等
//UILayer自动与stage保持同宽高
//Group大小不限
//
'use strict';
class StageFrameControl {
private static _instance: StageFrameControl;
static get instance(): StageFrameControl {
if(!this._instance) {
this._instance = new StageFrameControl();
}
return this._instance;
}
/*
* 地图滑动的容器和视域,作为一个Scroller,在最底层
* */
private mapScroll: eui.Scroller;
/*
* mapScroll的IViewport对象
* */
private mapViewportGroup: eui.Group;
/*
* 地图容器,地图跟着scroller滑动,child of mapViewportGroup
* */
private mapGroup: eui.Group;
/*
* scene容器,场景里的显示对象也跟着scroller滑动,child of mapViewportGroup
* */
private sceneGroup: eui.Group;
private uiRootLayer: eui.UILayer;
private topRootLayer: eui.UILayer;
/**新手引导层*/
private newBeeGuideLayer:eui.UILayer;
/**开场动画层级*/
private welcomeRootLayer: eui.UILayer;
public constructor() {
}
/*
* 布置stage的分层结构
* */
public init(stage:egret.Stage) {
this.mapGroup = new eui.Group();
//
this.sceneGroup = new eui.Group();
this.sceneGroup.touchThrough = true;
//
this.mapViewportGroup = new eui.Group();
this.mapViewportGroup.addChild(this.mapGroup);
this.mapViewportGroup.addChild(this.sceneGroup);
//
this.mapScroll = new eui.Scroller();
this.mapScroll.width = stage.stageWidth;
this.mapScroll.height = stage.stageHeight;
//
this.mapScroll.viewport = this.mapViewportGroup;
stage.addChild(this.mapScroll);
foxgame.Global.rootScroller = this.mapScroll;
//
this.welcomeRootLayer = new eui.UILayer();
stage.addChild(this.welcomeRootLayer);
foxgame.Global.welcomeLayer = this.welcomeRootLayer;
//
this.uiRootLayer = new eui.UILayer();
this.uiRootLayer.touchThrough = true;
stage.addChild(this.uiRootLayer);
foxgame.Global.uiLayer = this.uiRootLayer;
//
this.topRootLayer = new eui.UILayer();
this.topRootLayer.touchThrough = true;
this.topRootLayer.touchEnabled = false;
stage.addChild(this.topRootLayer);
foxgame.Global.topLayer = this.topRootLayer;
//新手引导
this.newBeeGuideLayer = new eui.UILayer();
this.newBeeGuideLayer.touchThrough = true;
this.newBeeGuideLayer.touchEnabled = false;
stage.addChild(this.newBeeGuideLayer);
foxgame.Global.newBeeGuideLayer = this.newBeeGuideLayer;
//
foxgame.Global.stageWidth = stage.stageWidth;
foxgame.Global.stageHeight = stage.stageHeight;
//initMapViewportGroupManager
foxgame.MapViewportGroupManager.instance.init(this.sceneGroup,this.mapGroup,this.mapViewportGroup);
}
/*
*
* */
public enableTouchTopLayer() {
this.topRootLayer.touchEnabled = true;
}
/*
*
* */
public disableTouchTopLayer() {
this.topRootLayer.touchEnabled = false;
}
/*
*
* */
public enterLoginFrame() {
}
/*
*
* */
public removeWelcomeLayer() {
if (this.welcomeRootLayer) {
if(this.welcomeRootLayer.parent)
this.welcomeRootLayer.parent.removeChild(this.welcomeRootLayer);
//
this.welcomeRootLayer = null;
foxgame.Global.welcomeLayer = null;
//
}
}
/**
* 设置滚动试图能否滑动
* */
public setScrollEnabled(state:boolean){
this.mapScroll.touchEnabled = state;
// this.mapScroll.viewport.scrollEnabled = state;
}
/**
* viewport
* */
public getScrollViewport(){
return this.mapViewportGroup;
}
}