Game Development Reference
In-Depth Information
Alternatively, you can use this:
application:setKeepAwake(false)
-- Allow the device to dim
Orientation
If you need to gather how the device is held at a particular point in time, you can query the orientation
of the device, like so:
application:getOrientation()
Application.PORTRAIT
Application.PORTRAIT_UPSIDE_DOWN
Application.LANDSCAPE_LEFT
Application.LANDSCAPE_RIGHT
Note The constants for the Application object all begin with a capital A , whereas the variables begin
with a lowercase a , as mentioned earlier.
You can use setOrientation to orient the device in the manner you want—for example, if you want a
game fixed in landscape mode, you need to explicitly set it in the settings or change the orientation
using the setOrientation function. Note that if you set this function, it overrides the project settings.
Scaling
One of the challenges faced by developers is ensuring that all screen resolutions are supported. One
way that many developers still address this is by setting the resolutions of the project to 320×480
and then using autoscaling for higher resolutions. The scale mode can be set from the project
properties window, but it can also be set via code using application:setScaleMode(theMode) .
Figure 9-15 shows the scaling options and how they affect the display.
 
 
Search WWH ::




Custom Search