Quote: " Can I set the resolution to getDeviceWidth and getDeviceHeight to overcome that problem?"
Yes you can, that's pretty much how I do things.
I've always used to Virtual Resolution system, but with a few tweaks to use the full screen area on any device.
Firstly establishing the native resolution and orientation using
devMin# and
devMax# to represent the shortest and longest edges of the display,
devAspect# represents the ratio of these ( >= 1.0 ) and
devIsLandscape to indicate landscape orientation.
devWidth# = GetDeviceWidth()
devHeight# = GetDeviceHeight()
devIsLandscape = ( devWidth# > devHeight# )
if devIsLandscape
devMin# = devHeight#
devMax# = devWidth#
else
devMin# = devWidth#
devMax# = devHeight#
endif
devAspect# = devMax# / devMin#
These values are then translated to match the working resolution - set by providing a new "min" value.
virtMin# = 320.0
virtMax# = virtMin# * devAspect#
At the start of the game and when the display orientation changes,
devIsLandscape is redetermined and the screen dimensions are calculated.
devIsLandscape = ( getDeviceWidth() > getDeviceHeight() )
if devIsLandscape
virtWidth# = virtMax#
virtHeight# = virtMin#
else
virtWidth# = virtMin#
virtHeight# = virtMax#
endif
SetVirtualResolution( virtWidth# , virtHeight# )
All code within the game uses these variables to calculate the positions of objects.
Where orientation will affect position, a conditional branch is used by checking
devIsLandscape
if devIsLandscape
mapXPos# = virtMin#
mapYPos# = 0
else
mapXPos# = 0
mapYPos# = virtMin#
endif
The above sets the position of an object to the right in landscape and below in portrait.
All sizes and positions are based on virtMin#, so for example for a tile map, with 8 tiles visible, I use something such as
tileSize# = virtMin# / 8.0
From here changing the working resolution of the game is simply a matter of changing the value set in
virtMin# and everything adjusts.