Getting Game always in Landscape on Android
Adrian Browne

Can you confirm the reliable way to get the full screen size on an Android phone?

innerwidth and innerheight give bad values.

I need to set the game in Landscape, which means finding out the width and height before laying out the scene objects.

In particluar, I have a frame which is not scalable ( wade.setLayerTransform(layerID,0,0); ) and therefore needs to know the screen size so it can be exactly placed.

1 Comment
Gio
Hi

There are several ways to deal with different screen sizes and orientations. If you want to post some code we may be able to help with your specific case. Our video tutorial number 4 covers the most common scenarios.

Some functions that may be useful:

wade.getScreenWidth()
wade.getScreenHeight()
wade.getContainerWidth()
wade.getContainerHeight()
wade.forceOrientation()
wade.setMinScreenSize()
wade.setMaxScreenSize()
SceneObject.setAlignment()
wade.setWindowMode()

Importantly, add an onResize() function to App, it will be called every time the screen size changes (e.g. when the screen is rotated).

I normally either set a fixed resolution using wade.setMinScreenSize() and wade.setMaxScreenSize(), or position my objects relative to an edge or corner of the screen with setAlignment().

One thing to keep in mind is that (by default) the screen size is initially set to the width and height that you specify for your wade_main_div in index.html, and after App.init() is executed, an onResize event is fired, and the game screen is resized to fit the device screen. This behavior can be changed by using some of the above functions in App.init()
Post a reply
Add Attachment
Submit Reply
Login to Reply