Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
How to support landscape and portrait games — Gideros Forum

How to support landscape and portrait games

SinisterSoftSinisterSoft Maintainer
edited December 2016 in Code snippets
For android you will need to alter the manifest, change "sensorLandscape" or "sensorPortrait" to "fullSensor".

Or, even easier, in the export plugins, tick 'requires' then within that also tick 'Full Orientation'. (in the 2016.12 version of Gideros - see screenshot).

Then in your lua code have this:
local landscape,oldLandscape=true,true
Then code your game init so that it uses landscape views...

and in an event that occurs regularly (eg an ENTER_FRAME attached to the stage) have this:
local device={application:getDeviceInfo()}
if device[1]=="Windows" or device[1]=="Mac OS" then
	if application:getDeviceHeight()>application:getDeviceWidth() then landscape=true else landscape=false end
else
	local orientation=application:getDeviceOrientation()
	if orientation=="landscapeLeft" or orientation=="landscapeRight" then landscape=true else landscape=false end
end
if landscape~=oldLandscape then
	oldLandscape=landscape
	print("Reformat display, landscape=",landscape)
 
end
Instead of printing the reformat message, you should reformat your layout for either portrait or landscape.

You can test on the Windows or OSX player by just resizing the screen to either something that looks landscape or portrait.

fullsensor.png
752 x 502 - 32K

Likes: n1cke, simwhi

Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
https://deluxepixel.com
+1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.