Class: Application `Application` class contains the common functions that's available to the current application. There is a global variable `application` of type `Application` to access these functions. --------------------------------------- Function: Application:openUrl Opens the given URL (Universal Resource Locator) in the appropriate application. URL can be one of the `http:`, `https:`, `tel:`, or `mailto:` schemes. The following example opens a web page in the browser: application:openUrl("http://www.giderosmobile.com") If `mailto:` scheme is specified, the user's e-mail client will be used to open a composer window containing the options specified in the URL. For example, the following URL contains a recipient (user@foo.com), a subject (Test), and a message body (Just a test): application:openUrl("mailto:user@foo.com?subject=Test&body=Just a test") Or to call a number: application:openUrl("tel:555-123-4567") --------------------------------------- Function: Application:getAccelerometer (obsolete) **This function is obsolete. Use [[Accelerometer]] class instead.** Returns the x, y, z coordinates of the accelerometer. Returns: 1. x coordinate of the accelerometer 2. y coordinate of the accelerometer 3. z coordinate of the accelerometer --------------------------------------- Function: Application:getLogicalWidth Returns the logical width of the application that is specified at the project properties. Returns: The logical width of the application --------------------------------------- Function: Application:getLogicalHeight Returns the logical height of the application that is specified at the project properties. Returns: The logical height of the application --------------------------------------- Function: Application:getDeviceWidth Returns the physical width of the device in pixels. For example, for iPhone 3GS this function returns 320 and for iPhone 4 (with retina display enabled) this function returns 640. Returns: The physical width of the device in pixels --------------------------------------- Function: Application:getDeviceHeight Returns the physical height of the device in pixels. For example, for iPhone 3GS this function returns 480 and for iPhone 4 (with retina display enabled) this function returns 960. Returns: The physical height of the device in pixels --------------------------------------- Function: Application:vibrate Vibrates the device. If the device doesn't support vibration, this function has no effect. --------------------------------------- Function: Application:getLocale Returns the device locale. The locale string is a combination of ISO 639-1 and ISO 3166-1. For example, en_US, ja_JP. Returns: The device locale --------------------------------------- Function: Application:getLanguage Returns the user language in ISO 639-1 format. Returns: The the user language --------------------------------------- Function: Application:setKeepAwake Controls the screen dimming and device sleeping of the device. When the application has no touches as user input for some period, the system puts the device into a sleep state where the screen dims. However some applications have no input and controlled by accelerometer or gyroscope only. For these kind applications, the screen should be kept awake by calling this function with parameter `true`. **Note:** This function has no effect on desktop. Parameters: keepAwake - (boolean) if true, screen is kept awake. Example: application:setKeepAwake(true) -- disable screen dimming and device sleeping application:setKeepAwake(false) -- enable screen dimming and device sleeping --------------------------------------- Function: Application:getLogicalTranslateX Returns the translation of automatic screen scaling on the x-axis. Returns: The translation of automatic screen scaling on the x-axis. --------------------------------------- Function: Application:getLogicalTranslateY Returns the translation of automatic screen scaling on the y-axis. Returns: The translation of automatic screen scaling on the y-axis. --------------------------------------- Function: Application:getLogicalScaleX Returns the scaling of automatic screen scaling on the x-axis. Returns: The scaling of automatic screen scaling on the x-axis. --------------------------------------- Function: Application:getLogicalScaleY Returns the scaling of automatic screen scaling on the y-axis. Returns: The scaling of automatic screen scaling on the y-axis. --------------------------------------- Function: Application:getDeviceInfo Returns information about device. - For iOS, returns 5 values: "iOS", iOS version, device type, user interface idiom and device model - For Android, returns 2 values: "Android", Android version - For Windows returns 1 value: "Windows" - For Mac OS X returns 1 value: "Mac OS" Returns: Information about device --------------------------------------- Function: Application:getContentWidth If the orientation is portrait, this function returns logical width. If the orientation is landscape, this function returns logical height. Returns: Logical width or logical height depending on orientation. --------------------------------------- Function: Application:getContentHeight If the orientation is portrait, this function returns logical height. If the orientation is landscape, this function returns logical width. Returns: Logical width or logical height depending on orientation. --------------------------------------- Function: Application:setBackgroundColor Sets the background color (or clear color) of the application in hexadecimal format. Default background color is white (0xffffff). Parameters: color - (number) background color in hexadecimal format --------------------------------------- Function: Application:getBackgroundColor Returns the background color (or clear color) of the application in hexadecimal format. Returns: The background color in hexadecimal format. --------------------------------------- Function: Application:setOrientation Sets the orientation of the application. Accepted values are: * Application.PORTRAIT = "portrait" * Application.PORTRAIT_UPSIDE_DOWN = "portraitUpsideDown" * Application.LANDSCAPE_LEFT = "landscapeLeft" * Application.LANDSCAPE_RIGHT = "landscapeRight" Parameters: orientation - (string) Example: application:setOrientation(Application.PORTRAIT) -- the buttons are on the bottom application:setOrientation(Application.PORTRAIT_UPSIDE_DOWN) -- the buttons are at the top application:setOrientation(Application.LANDSCAPE_LEFT) -- the buttons are on the right side application:setOrientation(Application.LANDSCAPE_RIGHT) -- the buttons are on the left side --------------------------------------- Function: Application:getOrientation Returns the orientation of the application. Returns: The orientation of the application --------------------------------------- Function: Application:setScaleMode Sets the automatic scale mode of the application. Accepted values are: * Application.NO_SCALE = "noScale" * Application.CENTER = "center" * Application.PIXEL_PERFECT = "pixelPerfect" * Application.LETTERBOX = "letterbox" * Application.CROP = "crop" * Application.STRETCH = "stretch" * Application.FIT_WIDTH = "fitWidth" * Application.FIT_HEIGHT = "fitHeight" Parameters: scaleMode - (string) --------------------------------------- Function: Application:getScaleMode Returns the automatic scale mode of the application. Returns: The automatic scale mode of the application --------------------------------------- Function: Application:setLogicalDimensions Sets the logical dimensions of the application. Parameters: width - (number) logical width height - (number) logical height --------------------------------------- Function: Application:setFps Sets the frame rate of the application. Accepted values are `30` and `60`. Parameters: fps - (number) the new frame rate of the application --------------------------------------- Function: Application:getFps Returns the frame rate of the application. Returns: The frame rate of the application. --------------------------------------- Function: Application:exit Terminates the application. Although this function is available to all platforms, it should be used on Android only. --------------------------------------- Class: os --------------------------------------- Function: os.timer Returns precise time in seconds relative to some arbitrary point. Returns: Precise time in seconds relative to some arbitrary point