• LayaBox在使用removeSelf()方法移除场景的时候应该注意什么


    程序入口存放每个ui界面的对象(这里有三个)

    // 程序入口
    class GameMain{
        public static mainUI:MainUI;       //用于存放游戏主页ui的成员属性
        public static secondUI:SecondUI;   //保存第二页ui
        public static thirdUI:ThirdUI;     //保存第三页ui
        private group:Array<number> = [];    //用于存放选中box的引索
        private allData:Array<any>;   //用于存放股票数据的数组
        private btnState:boolean = true;           //全选和取消全选按钮的状态
        private dataSource: Array<any> = []; //存储list中的每个box

    这里的三个UI成员属性都是public static属性的,方便全局调用

    下面是第三页ui的操作

    class ThirdUI extends ui.ThirdUI{
        constructor(){
            super();
            this.bingoAni.url = "../laya/assets/ui/output/bingo_ani.swf";
            this.bingoLogo.skin = "../laya/assets/ui/bingoLogo.png";
            this.return.skin = "../laya/assets/ui/return.png";
            this.return.on(Laya.Event.CLICK,this,this.onReturn);  //点击首页的我要申购按钮切换到求神的页面
        }
    
            //点击恭喜中签触发下面的事件
            private onReturn():void{
                //console.log("恭喜中签!!");
                this.removeSelf();      //移除当前(第三页)
                GameMain.mainUI.removeSelf();  //移除第一页
                GameMain.secondUI.y = -60;
                Laya.stage.addChild(GameMain.secondUI);
            }
    }

    这里是一个返回上一页的例子,注意如果要removeSelf()其他页面,显示其中一个页面的话,必须要移除彻底,即除开要显示的页面意外,其他所有的页面都要进行removeSelf()的操作,不能有漏,不然再addChild()回来的时候会报错。例如这里,我要显示第二页,那么我把第一和第三页都remov掉了,只addChild第二页。

  • 相关阅读:
    如何根据工单状态判断订单状态
    jquery移除click事件
    mysql字符串相关函数(并与sql server对比)
    bootstrap-table api
    js调用jquery的function函数
    Bootstrap table设置th,td内容水平、垂直居中
    Error:java: 无法访问javax.servlet.Servlet 找不到javax.servlet.Servlet的类文件
    html常用表单元素,按钮
    点击重置按钮,清空表单所有内容
    bootstrap table设置列宽
  • 原文地址:https://www.cnblogs.com/Alisa-Davillver/p/6398422.html
Copyright © 2020-2023  润新知