[]请问UI之间的场景切换要怎么写

var sg_sign = (function(_super){
function sg_sign(){
sg_sign.super(this);
this.btn_wxsign.on(Laya.Event.CLICK,this,this.onWxSign);
this.reset();
}
Laya.class(sg_sign,"sg_sign",_super);
var _proto = sg_sign.prototype;
_proto.reset = function(){
Laya.SoundManager.playMusic('res/sound/sign_bgm.mp3',0);
}
_proto.onWxSign = function(e){
onWxSign1();
}
return sg_sign;
})(ui.sg_signUI);




var sg_index = (function(_super){
function sg_index(){
sg_index.super(this);
this.indexDz.on(Laya.Event.CLICK,this,this.onIndexDz);
this.reset();
}
Laya.class(sg_index,"sg_index",_super);
var _proto = sg_index.prototype;
//初始化UI函数
_proto.reset = function(){
Laya.SoundManager.playMusic('res/sound/index_bgm.mp3',0);
}
_proto.onIndexDz = function(e){
indexDz();
}
return sg_index;
})(ui.sg_indexUI);



Laya.init(1350,760,Laya.WebGL);
Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE;
Laya.stage.alignH = "center";
Laya.stage.scaleMode = "showall";
Laya.stage.screenMode = "horizontal";
Laya.loader.load("res/atlas/sanguo.json",Laya.Handler.create(this,onLoaded),null,Laya.Loader.ATLAS);
function onLoaded(){
Laya.sg_sign = new sg_sign();
Laya.stage.addChild(Laya.sg_sign);
}
function onWxSign1(){
Laya.sg_sign.removeSelf();
Laya.Pool.recover("sg_sign",Laya.sg_sign);
Laya.sg_index = new sg_index();
Laya.stage.addChild(Laya.sg_index);
}

这样写可以吗
还有ui和代码创建出来 之间的切换要怎么写
已邀请:

cuixueying

赞同来自:

https://ask.layabox.com/question/5889
这里面有个简单的界面切换,你可以参考下,界面切换就是针对旧的界面进行移除,针对新的界面进行添加!

要回复问题请先

商务合作
商务合作