Egret之常见操作

获取舞台宽度和高度

如果是Main.ts中:

任何对象添加到舞台对象都可以通过

this.stage.stageWidth

this.stage.stageHeight

如果其他类中:

注意项目中要有game类,也就是egretProperties.json中要有{"name":"game"}

egret.MainContext.instance.stage.stageWidth

egret.MainContext.instance.stage.stageHeight

横屏显示

可以在 index.html 里的 body 部分修改 data-orientation 属性

也可以:

this.stage.orientation = egret.OrientationMode.LANDSCAPE;

缩放模式

建议使用fixedNarrow 

猜你喜欢

转载自my.oschina.net/u/3112095/blog/1788890
今日推荐