Game Development Reference
In-Depth Information
Note When you draw something on the shape, it is retained along with any subsequent draw over
whatever is already present on the shape. Therefore, it is best to start with obj:clear() to clear out
the shape before drawing.
The Application Object
You might want to get details such as the width of the device, the height of the device, or the locale
of the device, in case you are making multilingual apps. You might want to know if the device runs
iOS or Android, and so on. Gideros Studio has an extensive range of functions that allow us to query
the Application object to get these types of details. Here are a few examples:
local width = application:getDeviceWidth()
local height = application:getDeviceHeight()
local model = application:getDeviceInfo()
print("On " .. model .. " (" .. width .. " x " .. height .. " )" )
Note The variable that holds the Application object is application , not Application (note the
lowercase a ).
Look at the output pane in the IDE. If you are running this on a device player, the output would be
the device you are running it on, and if you are running the desktop player, as in this case, you will
see “Mac OS” or “Windows,” depending on which is being run. In the case of a mobile device,
application:getDeviceInfo() returns multiple values. For Android, it returns “Android” followed by
the version number, and on an iOS device, it returns five values: “iOS,” the version, the device type,
the UI idiom, and the device model. Here's some sample output from the iPhone running the Gideros
Player:
iOS 5.1 iPhone iPhone iPhone3,1
Keeping the Device Awake
If you need to perform some calculations and are worried that in that time the device might dim
and then go to sleep or switch off, you can ensure that the device does not dim simply by using the
following:
application:setKeepAwake(true)
-- Prevent the device from dimming
 
Search WWH ::




Custom Search