Common operations of Egret

Get stage width and height

If it is in Main.ts:

Any object added to the Stage object can be

this.stage.stageWidth

this.stage.stageHeight

If in other classes:

Note that there must be a game class in the project, that is, {"name":"game"} in egretProperties.json

egret.MainContext.instance.stage.stageWidth

egret.MainContext.instance.stage.stageHeight

Landscape display

You can modify the data-orientation attribute in the body section of index.html

You can also:

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

zoom mode

It is recommended to use fixedNarrow 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324529893&siteId=291194637