欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Laya_TS UI切换

程序员文章站 2022-05-05 12:30:02
...
/**
* name 
*/
module game{
	export class onClick extends Laya.Button{
		private dialog:ui.DAUI;
		constructor(){
			super();
			console.log("ddddddd");
			this.on(Laya.Event.MOUSE_DOWN,this,this.onClick);
		}
		private onClick(e:Event){
			console.log("this.name = " + this.name);
			if (this.name  == "btn1") {
				console.log("yesClick");
				this.dialog = new ui.DAUI();
				Laya.stage.addChild(this.dialog);
			}
			if (this.name  == "close") {
				console.log("closeClick");
				Laya.stage.removeChild(this.dialog);
			}
		}
	}
}

通过Laya.stage.addChild();和Laya.stage.removeChild();组合实现场景切换逻辑