了解一下stageFrameControler笔记

做新手引导层级放在最上层。这个是我添加的。还有好多地方需要注意的东西

//
//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;
    }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值