Back to top
Back to top
assert
Available since version: Gideros 2011.6
Description:
error if v nil or false, otherwise returns v
Syntax:
assert(v [, message])
Parameters:
Back to top
collectgarbage
Available since version: Gideros 2011.6
Description:
opts: stop, restart, collect, count, step, setpause, setstepmul
Syntax:
collectgarbage(opt [, arg])
Parameters:
Back to top
dofile
Available since version: Gideros 2011.6
Description:
executes as Lua chunk, default stdin, returns value
Syntax:
dofile(filename)
Parameters:
Back to top
error
Available since version: Gideros 2011.6
Description:
, 2=parent
Syntax:
error(message [, level])
Parameters:
Back to top
getfenv
Available since version: Gideros 2011.6
Description:
, 0=global env
Syntax:
getfenv(f)
Parameters:
Back to top
Back to top
ipairs
Available since version: Gideros 2011.6
Description:
returns an iterator function, table t and 0
Syntax:
ipairs(t)
Parameters:
Back to top
loadfile
Available since version: Gideros 2011.6
Description:
loads chunk without execution, returns chunk as function, else nil plus error
Syntax:
loadfile(filename)
Parameters:
Back to top
loadstring
Available since version: Gideros 2011.6
Description:
loads string as chunk, returns chunk as function, else nil plus error
Syntax:
loadstring(string [, chunkname])
Parameters:
Back to top
next
Available since version: Gideros 2011.6
Description:
, returns first index
Syntax:
next(table [, index])
Parameters:
Back to top
pairs
Available since version: Gideros 2011.6
Description:
returns the next function and table t plus a nil, iterates over all key-value pairs
Syntax:
pairs(t)
Parameters:
Back to top
pcall
Available since version: Gideros 2011.6
Description:
Syntax:
pcall(f, arg1, arg2, ...)
Parameters:
Back to top
print
Available since version: Gideros 2011.6
Description:
prints values to stdout using tostring
Syntax:
print(e1, e2, ...)
Parameters:
Back to top
rawequal
Available since version: Gideros 2011.6
Description:
non-metamethod v1==v2, returns boolean
Syntax:
rawequal(v1, v2)
Parameters:
Back to top
rawget
Available since version: Gideros 2011.6
Description:
non-metamethod get value of table[index], index != nil
Syntax:
rawget(table, index)
Parameters:
Back to top
rawset
Available since version: Gideros 2011.6
Description:
non-metamethod set value of table[index], index != nil
Syntax:
rawset(table, index, value)
Parameters:
Back to top
require
Available since version: Gideros 2011.6
Description:
loads package, updates _LOADED, returns boolean
Syntax:
require(packagename)
Parameters:
Back to top
setfenv
Available since version: Gideros 2011.6
Description:
, 0=global env
Syntax:
setfenv(f, table)
Parameters:
Back to top
Back to top
tonumber
Available since version: Gideros 2011.6
Description:
convert to number, returns number, nil if non-convertible, 2<=base<=36
Syntax:
tonumber(e [, base])
Parameters:
Back to top
tostring
Available since version: Gideros 2011.6
Description:
convert to string, returns string
Syntax:
tostring(e)
Parameters:
Back to top
type
Available since version: Gideros 2011.6
Description:
returns type of v as a string
Syntax:
type(v)
Parameters:
Back to top
unpack
Available since version: Gideros 2011.6
Description:
returns all elements from list
Syntax:
unpack(list)
Parameters:
Back to top
xpcall
Available since version: Gideros 2011.6
Description:
pcall function f with new error handler err
Syntax:
xpcall(f, err)
Parameters:
Back to top
_G
Available since version: Gideros 2011.6
Description:
holds global environment, setfenv changes environments
Value:
_G = ""
Back to top
_VERSION
Available since version: Gideros 2011.6
Description:
current interpreter version "Lua 5.1.x"
Value:
_VERSION = ""
Back to top
Accelerometer
Supported platforms:
Available since version: Gideros 2012.8
Description:
Common uses and examples:
local accelerometer = Accelerometer.new()
accelerometer:start()
---
local x, y, z = accelerometer:getAcceleration()
print(x, y, z)
Back to top
Accelerometer.isAvailable
Available since version: Gideros 2012.8
Description:
Returns true
if accelerometer is available for this platform, false
otherwise.
Syntax:
Accelerometer.isAvailable()
Back to top
Accelerometer.new
Available since version: Gideros 2012.8
Description:
Creates new Accelerometer instance
Syntax:
Accelerometer.new()
Back to top
Accelerometer:getAcceleration
Available since version: Gideros 2012.8
Description:
Returns the 3-axis acceleration measured by the accelerometer.
Syntax:
Accelerometer:getAcceleration()
Back to top
Accelerometer:start
Available since version: Gideros 2012.8
Description:
Starts the generation of accelerometer samples.
Syntax:
Accelerometer:start()
Back to top
Accelerometer:stop
Available since version: Gideros 2012.8
Description:
Stops the generation of accelerometer samples.
Syntax:
Accelerometer:stop()
Back to top
AlertDialog
Supported platforms:
Available since version: Gideros 2012.8
Description:
The
AlertDialog class is used to display native alert dialogs with one, two or three buttons. Cancel button
is mandatory but other two buttons are optional. When the user presses any button in the alert dialog,
it's dismissed and
Event.COMPLETE
event is dispatched.
If alert dialog is dismissed by any other means (by pressing back button on Android or by pressing close button on desktop), it behaves as cancel button is pressed.
Common uses and examples:
local alertDialog = AlertDialog.new("This is my title", "And my message", "Cancel", "Yes", "No")
local function onComplete(event)
print(event.buttonIndex, event.buttonText)
end
alertDialog:addEventListener(Event.COMPLETE, onComplete)
alertDialog:show()
Back to top
AlertDialog.new
Available since version: Gideros 2012.8
Description:
Syntax:
AlertDialog.new(title, message, cancelButton, button1, button2)
Parameters:
- title: (string) The string that appears in the receiver's title bar. Can be empty string.
- message: (string) Descriptive text that provides more details than the title. Can be empty string.
- cancelButton: (string) The text of the cancel button.
- button1: (string, optional) The text of the 1st optional button.
- button2: (string, optional) The text of the 2st optional button.
Back to top
AlertDialog:hide
Available since version: Gideros 2012.8
Description:
Hides the alert dialog.
Syntax:
AlertDialog:hide()
Back to top
AlertDialog:show
Available since version: Gideros 2012.8
Description:
Shows the alert dialog.
Syntax:
AlertDialog:show()
Back to top
Event.COMPLETE
Available since version: Gideros 2012.8
Description:
This event is dispatched when user presses any button on AlertDialog or the dialog is dismissed by any other reason.
Value:
Event.COMPLETE = "complete"
Event properties:
- buttonIndex: (number) the index of the button pressed. It is nil when cancel button is pressed, 1 when 1st button is pressed and 2 when 2nd button is pressed.
- buttonText: (string) the text of the button pressed
Back to top
Application
Supported platforms:
Available since version: Gideros 2011.6
Description:
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.
Back to top
Application:canOpenUrl
Available since version: Gideros 2013.06
Description:
Tests if it is possible to open provided url using Application:openUrl
method
Syntax:
Application:canOpenUrl(url)
Parameters:
- url: (string) url to test if can be opened
Back to top
Application:exit
Available since version: Gideros 2012.2.2
Description:
Terminates the application. Although this function is available to all platforms, it should be used on Android only.
Syntax:
Application:exit()
Back to top
Application:getApiVersion
Available since version: Gideros 2012.08.2
Description:
Returns the API version.
Syntax:
Application:getApiVersion()
Back to top
Application:getBackgroundColor
Available since version: Gideros 2011.6
Description:
Returns the background color (or clear color) of the application in hexadecimal format.
Syntax:
Application:getBackgroundColor()
Back to top
Application:getContentHeight
Available since version: Gideros 2011.6
Description:
If the orientation is portrait, this function returns logical height. If the orientation is landscape, this function
returns logical width.
Syntax:
Application:getContentHeight()
Back to top
Application:getContentWidth
Available since version: Gideros 2011.6
Description:
If the orientation is portrait, this function returns logical width. If the orientation is landscape, this function
returns logical height.
Syntax:
Application:getContentWidth()
Back to top
Application:getDeviceHeight
Available since version: Gideros 2011.6
Description:
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.
Syntax:
Application:getDeviceHeight()
Back to top
Application:getDeviceInfo
Available since version: Gideros 2011.6
Description:
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"
Syntax:
Application:getDeviceInfo()
Back to top
Application:getDeviceWidth
Available since version: Gideros 2011.6
Description:
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.
Syntax:
Application:getDeviceWidth()
Back to top
Application:getFps
Available since version: Gideros 2012.2.2
Description:
Returns the frame rate of the application.
Syntax:
Application:getFps()
Back to top
Application:getLanguage
Available since version: Gideros 2011.6
Description:
Returns the user language in ISO 639-1 format.
Syntax:
Application:getLanguage()
Back to top
Application:getLocale
Available since version: Gideros 2011.6
Description:
Returns the device locale. The locale string is a combination of ISO 639-1 and ISO 3166-1. For example, en_US, ja_JP.
Syntax:
Application:getLocale()
Back to top
Application:getLogicalHeight
Available since version: Gideros 2011.6
Description:
Returns the logical height of the application that is specified at the project properties.
Syntax:
Application:getLogicalHeight()
Back to top
Application:getLogicalScaleX
Available since version: Gideros 2011.6
Description:
Returns the scaling of automatic screen scaling on the x-axis.
Syntax:
Application:getLogicalScaleX()
Back to top
Application:getLogicalScaleY
Available since version: Gideros 2011.6
Description:
Returns the scaling of automatic screen scaling on the y-axis.
Syntax:
Application:getLogicalScaleY()
Back to top
Application:getLogicalTranslateX
Available since version: Gideros 2011.6
Description:
Returns the translation of automatic screen scaling on the x-axis.
Syntax:
Application:getLogicalTranslateX()
Back to top
Application:getLogicalTranslateY
Available since version: Gideros 2011.6
Description:
Returns the translation of automatic screen scaling on the y-axis.
Syntax:
Application:getLogicalTranslateY()
Back to top
Application:getLogicalWidth
Available since version: Gideros 2011.6
Description:
Returns the logical width of the application that is specified at the project properties.
Syntax:
Application:getLogicalWidth()
Back to top
Application:getOrientation
Available since version: Gideros 2011.6
Description:
Returns the orientation of the application.
Syntax:
Application:getOrientation()
Back to top
Application:getScaleMode
Available since version: Gideros 2012.2.2
Description:
Returns the automatic scale mode of the application.
Syntax:
Application:getScaleMode()
Back to top
Application:getScreenDensity
Available since version: Gideros 2012.09.2
Description:
Returns the screen density in pixels per inch. If screen density information is not available, returns nil
.
Syntax:
Application:getScreenDensity()
Back to top
Application:getTextureMemoryUsage
Available since version: Gideros 2012.08.3
Description:
Returns the texture memory usage (in Kbytes).
Syntax:
Application:getTextureMemoryUsage()
Back to top
Application:openUrl
Available since version: Gideros 2011.6
Description:
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")
Syntax:
Application:openUrl(url)
Parameters:
- url: (string) url to open
Back to top
Application:setBackgroundColor
Available since version: Gideros 2011.6
Description:
Sets the background color (or clear color) of the application in hexadecimal format. Default background color is white (0xffffff).
Syntax:
Application:setBackgroundColor(color)
Parameters:
- color: (number) background color in hexadecimal format
Back to top
Application:setFps
Available since version: Gideros 2012.2.2
Description:
Sets the frame rate of the application. Accepted values are 30
and 60
.
Syntax:
Application:setFps(fps)
Parameters:
- fps: (number) the new frame rate of the application
Back to top
Application:setKeepAwake
Available since version: Gideros 2011.6
Description:
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.
Syntax:
Application:setKeepAwake(keepAwake)
Parameters:
- keepAwake: (boolean) if true, screen is kept awake.
Examples:
application:setKeepAwake(true) -- disable screen dimming and device sleeping
application:setKeepAwake(false) -- enable screen dimming and device sleeping
Back to top
Application:setLogicalDimensions
Available since version: Gideros 2012.2.2
Description:
Sets the logical dimensions of the application.
Syntax:
Application:setLogicalDimensions(width, height)
Parameters:
- width: (number) logical width
- height: (number) logical height
Back to top
Application:setOrientation
Available since version: Gideros 2011.6
Description:
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"
Syntax:
Application:setOrientation(orientation)
Parameters:
Examples:
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
Back to top
Application:setScaleMode
Available since version: Gideros 2012.2.2
Description:
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"
Syntax:
Application:setScaleMode(scaleMode)
Parameters:
Back to top
Application:vibrate
Available since version: Gideros 2011.6
Description:
Vibrates the device. If the device doesn't support vibration, this function has no effect.
Syntax:
Application:vibrate()
Back to top
Application.LANDSCAPE_LEFT
Available since version: Gideros 2011.6
Description:
Value:
Application.LANDSCAPE_LEFT = "landscapeLeft"
Back to top
Application.LANDSCAPE_RIGHT
Available since version: Gideros 2011.6
Description:
Value:
Application.LANDSCAPE_RIGHT = "landscapeRight"
Back to top
Application.PORTRAIT
Available since version: Gideros 2011.6
Description:
Value:
Application.PORTRAIT = "portrait"
Back to top
Application.PORTRAIT_UPSIDE_DOWN
Available since version: Gideros 2011.6
Description:
Value:
Application.PORTRAIT_UPSIDE_DOWN = "portraitUpsideDown"
Back to top
b2
Supported platforms:
Available since version: Gideros 2011.6
Description:
To load the Box2D library, call
require "box2d"
. After loading Box2D library,
b2 table stores all
classes and functions related to Box2D physics library.
Back to top
b2.createDistanceJointDef
Available since version: Gideros 2011.6
Description:
Creates and returns a distance joint definition table with the bodies, anchors, and length using the world anchors.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a distance joint).
Syntax:
b2.createDistanceJointDef(bodyA, bodyB, anchorAx, anchorAy, anchorBx, anchorBy)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- anchorAx: (number) the x coordinate of the world anchor point of bodyA
- anchorAy: (number) the y coordinate of the world anchor point of bodyA
- anchorBx: (number) the x coordinate of the world anchor point of bodyB
- anchorBy: (number) the y coordinate of the world anchor point of bodyB
Back to top
b2.createFrictionJointDef
Available since version: Gideros 2011.6
Description:
Creates and returns a friction joint definition table with the bodies and local anchors using a world anchor point.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a friction joint).
Syntax:
b2.createFrictionJointDef(bodyA, bodyB, anchorx, anchory)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- anchorx: (number) the x coordinate of the world anchor point
- anchory: (number) the y coordinate of the world anchor point
Back to top
b2.createGearJointDef
Available since version: Gideros 2011.6
Description:
Creates and returns a gear joint definition table.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a gear joint).
Syntax:
b2.createGearJointDef(bodyA, bodyB, joint1, joint2, ratio)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- joint1: (b2.Joint) the first revolute/prismatic joint attached to the gear joint
- joint2: (b2.Joint) the second revolute/prismatic joint attached to the gear joint
- ratio: (number, default = 1) the gear ratio
Back to top
b2.createMouseJointDef
Available since version: Gideros 2011.6
Description:
Creates and returns a mouse joint definition table with the bodies, world target point, maxForce and optional frequencyHz and dampingRatio.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a mouse joint).
Syntax:
b2.createMouseJointDef(bodyA, bodyB, targetx, targety, maxForce, frequencyHz, dampingRatio)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- targetx: (number) the x coordinate of the world target point
- targety: (number) the y coordinate of the world target point
- maxForce: (number) the maximum constraint force that can be exerted to move the candidate body
- frequencyHz: (number, default = 5) the response speed
- dampingRatio: (number, default = 0.7) the damping ratio. 0 = no damping, 1 = critical damping
Back to top
b2.createPrismaticJointDef
Available since version: Gideros 2011.6
Description:
Creates and returns a prismatic joint definition table with the bodies, anchors, axis, and reference angle using the world anchor and world axis.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a prismatic joint).
Syntax:
b2.createPrismaticJointDef(bodyA, bodyB, anchorx, anchory, axisx, axisy)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- anchorx: (number) the x coordinate of the world anchor point
- anchory: (number) the y coordinate of the world anchor point
- axisx: (number) the x coordinate of the world axis
- axisy: (number) the y coordinate of the world axis
Back to top
b2.createPulleyJointDef
Available since version: Gideros 2011.6
Description:
Creates and returns a pulley joint definition table with the bodies, anchors, lengths, max lengths, and ratio using the world anchors.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a pulley joint).
Syntax:
b2.createPulleyJointDef(bodyA, bodyB, groundAnchorAx, groundAnchorAy, groundAnchorBx, groundAnchorBy, anchorAx, anchorAy, anchorBx, anchorBy, ratio)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- groundAnchorAx: (number) the x coordinate of the first ground anchor in world coordinates. This point never moves.
- groundAnchorAy: (number) the y coordinate of the first ground anchor in world coordinates. This point never moves.
- groundAnchorBx: (number) the x coordinate of the second ground anchor in world coordinates. This point never moves.
- groundAnchorBy: (number) the y coordinate of the second ground anchor in world coordinates. This point never moves.
- anchorAx: (number) the x coordinate of the world anchor point of bodyA
- anchorAy: (number) the y coordinate of the world anchor point of bodyA
- anchorBx: (number) the x coordinate of the world anchor point of bodyB
- anchorBy: (number) the y coordinate of the world anchor point of bodyB
- ratio: (number) the pulley ratio, used to simulate a block-and-tackle
Back to top
b2.createRevoluteJointDef
Available since version: Gideros 2011.6
Description:
Creates and returns a revolute joint definition table with the bodies, local anchors, and reference angle using a world anchor point.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a revolute joint).
Syntax:
b2.createRevoluteJointDef(bodyA, bodyB, anchorx, anchory)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- anchorx: (number) the x coordinate of the world anchor point
- anchory: (number) the y coordinate of the world anchor point
Examples:
local jointdef = b2.createRevoluteJointDef(bodyA, bodyB, anchorx, anchory)
local joint = b2.World:createJoint(jointdef)
Back to top
b2.createRopeJointDef
Available since version: Gideros 2012.09.3
Description:
Creates and returns a rope joint definition table with the bodies and local anchors using a world anchor point.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a rope joint).
Syntax:
b2.createRopeJointDef(bodyA, bodyB, anchorAx, anchorAy, anchorBx, anchorBy, maxLength)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- anchorAx: (number) the x coordinate of the world anchor point of bodyA
- anchorAy: (number) the y coordinate of the world anchor point of bodyA
- anchorBx: (number) the x coordinate of the world anchor point of bodyB
- anchorBy: (number) the y coordinate of the world anchor point of bodyB
- maxLength: (number) the maximum length of the rope
Back to top
b2.createWeldJointDef
Available since version: Gideros 2011.6
Description:
Creates and returns a weld joint definition table with the bodies, anchors, and reference angle using a world anchor point.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a weld joint).
Syntax:
b2.createWeldJointDef(bodyA, bodyB, anchorAx, anchorAy, anchorBx, anchorBy)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- anchorAx: (number) the x coordinate of the world anchor point of bodyA
- anchorAy: (number) the y coordinate of the world anchor point of bodyA
- anchorBx: (number) the x coordinate of the world anchor point of bodyB
- anchorBy: (number) the y coordinate of the world anchor point of bodyB
Back to top
b2.createWheelJointDef
Available since version: Gideros 2011.6
Description:
Creates and returns a wheel joint definition table.
(Please refer to [[b2.World:createJoint]] function for more information about all the information needed to create a wheel joint).
Syntax:
b2.createWheelJointDef(bodyA, bodyB, anchorx, anchory, axisx, axisy)
Parameters:
- bodyA: (b2.Body) the first attached body
- bodyB: (b2.Body) the second attached body
- anchorx: (number) the x coordinate of the world anchor point
- anchory: (number) the y coordinate of the world anchor point
- axisx: (number) the x coordinate of the world translation axis in bodyA
- axisy: (number) the y coordinate of the world translation axis in bodyA
Back to top
b2.getScale
Available since version: Gideros 2011.6
Description:
Returns the global pixels to meters scale (Please refer to [[b2.setScale]] function for more information about pixels to meters scaling).
Syntax:
b2.getScale()
Back to top
b2.setScale
Available since version: Gideros 2011.6
Description:
Box2D is tuned for MKS (meters-kilogram-second) units and the size of moving objects should roughly between 0.1 and 10 meters.
If you directly use the pixels as your units, unfortunately this will lead to a poor simulation and possibly weird behavior.
Gideros uses an internal scale system to convert between meters and pixels. By default, the value of this scale is 30
which means 1 meter = 30 pixels. This is a global value and effects all the physics system. Therefore, it is recommended to set this
value once before any physical objects are instantiated (e.g. right after calling require "box2d"
)
Syntax:
b2.setScale(scale)
Parameters:
- scale: (number) - the global pixels to meters scale
Back to top
b2.DISTANCE_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.DISTANCE_JOINT = 3
Back to top
b2.DYNAMIC_BODY
Available since version: Gideros 2011.6
Description:
Value:
b2.DYNAMIC_BODY = 2
Back to top
b2.FRICTION_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.FRICTION_JOINT = 9
Back to top
b2.GEAR_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.GEAR_JOINT = 6
Back to top
b2.KINEMATIC_BODY
Available since version: Gideros 2011.6
Description:
Value:
b2.KINEMATIC_BODY = 1
Back to top
b2.MOUSE_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.MOUSE_JOINT = 5
Back to top
b2.PRISMATIC_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.PRISMATIC_JOINT = 2
Back to top
b2.PULLEY_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.PULLEY_JOINT = 4
Back to top
b2.REVOLUTE_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.REVOLUTE_JOINT = 1
Back to top
b2.ROPE_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.ROPE_JOINT = 10
Back to top
b2.STATIC_BODY
Available since version: Gideros 2011.6
Description:
Value:
b2.STATIC_BODY = 0
Back to top
b2.WELD_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.WELD_JOINT = 8
Back to top
b2.WHEEL_JOINT
Available since version: Gideros 2011.6
Description:
Value:
b2.WHEEL_JOINT = 7
Back to top
Back to top
b2.Body:applyAngularImpulse
Available since version: Gideros 2011.6
Description:
Applies an angular impulse.
Syntax:
b2.Body:applyAngularImpulse(impulse)
Parameters:
- impulse: (number) the angular impulse in units of kg*m*m/s
Back to top
b2.Body:applyForce
Available since version: Gideros 2011.6
Description:
Applies a force at a world point. If the force is not
applied at the center of mass, it will generate a torque and
affect the angular velocity. This wakes up the body.
Syntax:
b2.Body:applyForce(forcex, forcey, pointx, pointy)
Parameters:
- forcex: (number)
- forcey: (number)
- pointx: (number) the x coordinate of the world position of the point of application
- pointy: (number) the y coordinate of the world position of the point of application
Back to top
b2.Body:applyLinearImpulse
Available since version: Gideros 2011.6
Description:
Applies an impulse at a point. This immediately modifies the velocity. It also
modifies the angular velocity if the point of application is not at the center of
mass. This wakes up the body.
Syntax:
b2.Body:applyLinearImpulse(impulsex, impulsey, pointx, pointy)
Parameters:
- impulsex: (number) the x coordinate of the world impulse vector, usually in N-seconds or kg-m/s
- impulsey: (number) the y coordinate of the world impulse vector, usually in N-seconds or kg-m/s
- pointx: (number) the x coordinate of the world position of the point of application
- pointy: (number) the y coordinate of the world position of the point of application
Back to top
b2.Body:applyTorque
Available since version: Gideros 2011.6
Description:
Applies a torque. This affects the angular velocity without affecting
the linear velocity of the center of mass. This wakes up the body.
Syntax:
b2.Body:applyTorque(torque)
Parameters:
- torque: (number) , usually in N-m
Back to top
b2.Body:createFixture
Available since version: Gideros 2011.6
Description:
Creates a fixture and attach it to this body. If the density is non-zero, this function automatically
updates the mass of the body. Contacts are not created until the next time step. The fixture definition is given
as a ordinary table. The fields of the fixture definition table are:
- **shape**: (b2.Shape) The shape, this must be set.
- **friction**: (number) The friction coefficient, usually in the range [0,1].
- **restitution**: (number) The restitution (elasticity) usually in the range [0,1].
- **density**: (number) The density, usually in kg/m^2.
- **isSensor**: (boolean) A sensor shape collects contact information but never generates a collision response.
- **filter**: (table) Contact filtering data. The definition of contact filtering data is given at
b2.Fixture:setFilterData
function.
The unset fields gets default values.
- *Warning:** This function is locked during callbacks.
Syntax:
b2.Body:createFixture(fixtureDef)
Parameters:
Back to top
b2.Body:destroyFixture
Available since version: Gideros 2011.6
Description:
Destroy a fixture. This removes the fixture from the broad-phase and destroys all
contacts associated with this fixture. This will automatically adjust the mass of the body if the
body is dynamic and the fixture has positive density. All fixtures attached to a body are implicitly
destroyed when the body is destroyed.
- *Warning:** This function is locked during callbacks.
Syntax:
b2.Body:destroyFixture(fixture)
Parameters:
- fixture: (b2.Fixture) the fixture to be removed
Back to top
b2.Body:getAngle
Available since version: Gideros 2011.6
Description:
Returns the current world rotation angle in radians.
Syntax:
b2.Body:getAngle()
Back to top
b2.Body:getAngularDamping
Available since version: Gideros 2012.2.2
Description:
Returns the angular damping of the body.
Syntax:
b2.Body:getAngularDamping()
Back to top
b2.Body:getAngularVelocity
Available since version: Gideros 2011.6
Description:
Returns the angular velocity.
Syntax:
b2.Body:getAngularVelocity()
Back to top
b2.Body:getGravityScale
Available since version: Gideros 2012.2.2.1
Description:
Returns the gravity scale of the body.
Syntax:
b2.Body:getGravityScale()
Back to top
b2.Body:getInertia
Available since version: Gideros 2012.2.2
Description:
Returns the rotational inertia of the body about the local origin in kg-m^2.
Syntax:
b2.Body:getInertia()
Back to top
b2.Body:getLinearDamping
Available since version: Gideros 2012.2.2
Description:
Returns the linear damping of the body.
Syntax:
b2.Body:getLinearDamping()
Back to top
b2.Body:getLinearVelocity
Available since version: Gideros 2011.6
Description:
Returns the linear velocity of the center of mass.
Syntax:
b2.Body:getLinearVelocity()
Back to top
b2.Body:getLocalCenter
Available since version: Gideros 2012.2.2
Description:
Returns the local position of the center of mass.
Syntax:
b2.Body:getLocalCenter()
Back to top
b2.Body:getLocalPoint
Available since version: Gideros 2012.09.6
Description:
Returns the local coordinates of a point given the world coordinates.
Syntax:
b2.Body:getLocalPoint(x, y)
Parameters:
- x: (number) x coordinate of the world point
- y: (number) y coordinate of the world point
Back to top
b2.Body:getLocalVector
Available since version: Gideros 2012.09.6
Description:
Returns the local coordinates of a vector given the world coordinates.
Syntax:
b2.Body:getLocalVector(x, y)
Parameters:
- x: (number) x coordinate of the world vector
- y: (number) y coordinate of the world vector
Back to top
b2.Body:getMass
Available since version: Gideros 2012.2.2
Description:
Returns the total mass of the body in kilograms (kg).
Syntax:
b2.Body:getMass()
Back to top
b2.Body:getPosition
Available since version: Gideros 2011.6
Description:
Returns the world body origin position.
Syntax:
b2.Body:getPosition()
Back to top
b2.Body:getWorldCenter
Available since version: Gideros 2012.2.2
Description:
Returns the world position of the center of mass.
Syntax:
b2.Body:getWorldCenter()
Back to top
b2.Body:getWorldPoint
Available since version: Gideros 2012.09.6
Description:
Returns the world coordinates of a point given the local coordinates.
Syntax:
b2.Body:getWorldPoint(x, y)
Parameters:
- x: (number) x coordinate of the local point
- y: (number) y coordinate of the local point
Back to top
b2.Body:getWorldVector
Available since version: Gideros 2012.09.6
Description:
Returns the world coordinates of a vector given the local coordinates.
Syntax:
b2.Body:getWorldVector(x, y)
Parameters:
- x: (number) x coordinate of the local vector
- y: (number) y coordinate of the local vector
Back to top
b2.Body:isActive
Available since version: Gideros 2011.6
Description:
Returns the active state of the body.
Syntax:
b2.Body:isActive()
Back to top
b2.Body:isAwake
Available since version: Gideros 2011.6
Description:
Returns the sleeping state of this body. Returns true
if body is awake (not sleeping), false
otherwise.
Syntax:
b2.Body:isAwake()
Back to top
b2.Body:isBullet
Available since version: Gideros 2012.09.6
Description:
Syntax:
b2.Body:isBullet()
Back to top
b2.Body:isFixedRotation
Available since version: Gideros 2012.09.6
Description:
Syntax:
b2.Body:isFixedRotation()
Back to top
b2.Body:isSleepingAllowed
Available since version: Gideros 2012.09.6
Description:
Syntax:
b2.Body:isSleepingAllowed()
Back to top
b2.Body:setActive
Available since version: Gideros 2011.6
Description:
Sets the active state of the body. An inactive body is not simulated and cannot be collided with or woken up.
If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false,
all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are
otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies.
Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries.
Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a [[b2.World]] object and
remains in the body list.
Syntax:
b2.Body:setActive(flag)
Parameters:
- flag: (boolean) active flag
Back to top
b2.Body:setAngle
Available since version: Gideros 2011.6
Description:
Sets the current world rotation angle in radians.
Syntax:
b2.Body:setAngle(angle)
Parameters:
- angle: (number) world rotation angle in radians
Back to top
b2.Body:setAngularDamping
Available since version: Gideros 2012.2.2
Description:
Sets the angular damping of the body.
Syntax:
b2.Body:setAngularDamping(angularDamping)
Parameters:
- angularDamping: (number) new angular damping of the body
Back to top
b2.Body:setAngularVelocity
Available since version: Gideros 2011.6
Description:
Sets the angular velocity.
Syntax:
b2.Body:setAngularVelocity(omega)
Parameters:
- omega: (number) the new angular velocity in radians/second
Back to top
b2.Body:setAwake
Available since version: Gideros 2012.2.2.1
Description:
Set the sleep state of the body. A sleeping body has very low CPU cost.
Syntax:
b2.Body:setAwake(awake)
Parameters:
- awake: (boolean) set to true to wake body, false to put it to sleep
Back to top
b2.Body:setBullet
Available since version: Gideros 2012.09.6
Description:
Syntax:
b2.Body:setBullet(flag)
Parameters:
Back to top
b2.Body:setFixedRotation
Available since version: Gideros 2012.09.6
Description:
Syntax:
b2.Body:setFixedRotation(flag)
Parameters:
Back to top
b2.Body:setGravityScale
Available since version: Gideros 2012.2.2.1
Description:
Sets the gravity scale of the body.
Syntax:
b2.Body:setGravityScale(scale)
Parameters:
- scale: (number) new gravity scale of the body
Back to top
b2.Body:setLinearDamping
Available since version: Gideros 2012.2.2
Description:
Sets the linear damping of the body.
Syntax:
b2.Body:setLinearDamping(linearDamping)
Parameters:
- linearDamping: (number) new linear damping of the body
Back to top
b2.Body:setLinearVelocity
Available since version: Gideros 2011.6
Description:
Sets the linear velocity of the center of mass.
Syntax:
b2.Body:setLinearVelocity(x, y)
Parameters:
- x: (number) x coordinate of the linear velocity
- y: (number) y coordinate of the linear velocity
Back to top
b2.Body:setPosition
Available since version: Gideros 2011.6
Description:
Sets the world body origin position.
Syntax:
b2.Body:setPosition(x, y)
Parameters:
- x: (number) x coordinate of the position
- y: (number) y coordinate of the position
Back to top
b2.Body:setSleepingAllowed
Available since version: Gideros 2012.09.6
Description:
Syntax:
b2.Body:setSleepingAllowed(flag)
Parameters:
Back to top
b2.ChainShape
Supported platforms:
Available since version: Gideros 2012.2.2
Description:
A chain shape is a free form sequence of line segments. The chain has two-sided collision, so you can use inside
and outside collision. Therefore, you may use any winding order. Connectivity information is used to create smooth collisions.
- *Note:** The chain will not collide properly if there are self-intersections.
Back to top
b2.ChainShape.new
Available since version: Gideros 2011.6
Description:
Syntax:
b2.ChainShape.new()
Back to top
b2.ChainShape:createChain
Available since version: Gideros 2011.6
Description:
Creates a chain with isolated end vertices.
Syntax:
b2.ChainShape:createChain(vertices)
Parameters:
- vertices: A list of numbers that contains the x, y coordinates of the vertices sequentially
Back to top
b2.ChainShape:createLoop
Available since version: Gideros 2011.6
Description:
Creates a loop. This automatically adjusts connectivity.
Syntax:
b2.ChainShape:createLoop(vertices)
Parameters:
- vertices: A list of numbers that contains the x, y coordinates of the vertices sequentially
Back to top
Back to top
b2.CircleShape.new
Available since version: Gideros 2011.6
Description:
Creates a new
b2.CircleShape instance and optionally set its center point and radius.
If this function is called with more than 3 parameters,
b2.CircleShape instance
is created and its center point and radius are set. If this function is called without any
paramaters, only
b2.CircleShape instance is created and you should set the center
point and radius with [[b2.CircleShape:set]] function.
Syntax:
b2.CircleShape.new(centerx, centery, radius)
Parameters:
- centerx: (number, optional) the x coordinate of the center
- centery: (number, optional) the y coordinate of the center
- radius: (number, optional) the radius
Back to top
b2.CircleShape:set
Available since version: Gideros 2011.6
Description:
Sets the center point and radius of this instance.
Syntax:
b2.CircleShape:set(centerx, centery, radius)
Parameters:
- centerx: (number, optional) the x coordinate of the center
- centery: (number, optional) the y coordinate of the center
- radius: (number, optional) the radius
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
b2.DebugDraw
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
b2.DebugDraw class is used to provide debug drawing of physical entities in your application.
Common uses and examples:
local debugDraw = b2.DebugDraw.new()
world:setDebugDraw(debugDraw)
stage:addChild(debugDraw)
Back to top
b2.DebugDraw.new
Available since version: Gideros 2011.6
Description:
Syntax:
b2.DebugDraw.new()
Back to top
b2.DebugDraw:appendFlags
Available since version: Gideros 2011.6
Description:
Append flags to the current flags.
Syntax:
b2.DebugDraw:appendFlags(flags)
Parameters:
- flags: (number) debug draw flags
Back to top
b2.DebugDraw:clearFlags
Available since version: Gideros 2011.6
Description:
Clear flags from the current flags.
Syntax:
b2.DebugDraw:clearFlags(flags)
Parameters:
- flags: (number) debug draw flags
Back to top
b2.DebugDraw:getFlags
Available since version: Gideros 2011.6
Description:
Returns the debug drawing flags.
Syntax:
b2.DebugDraw:getFlags()
Back to top
b2.DebugDraw:setFlags
Available since version: Gideros 2011.6
Description:
Sets the debug drawing flags. These flags are available:
b2.DebugDraw.SHAPE_BIT
b2.DebugDraw.JOINT_BIT
b2.DebugDraw.AABB_BIT
b2.DebugDraw.PAIR_BIT
b2.DebugDraw.CENTER_OF_MASS_BIT
b2.DebugDraw.SHAPE_BIT
is set by default.
Because Lua doesn't support bitwise operations by default, you can use
operator to combine flags.
Syntax:
b2.DebugDraw:setFlags(flags)
Parameters:
- flags: (number) debug draw flags
Examples:
local debugDraw = b2.DebugDraw.new()
debugDraw:setFlags(b2.DebugDraw.SHAPE_BIT b2.DebugDraw.JOINT_BIT)
Back to top
b2.DebugDraw.AABB_BIT
Available since version: Gideros 2011.6
Description:
Value:
b2.DebugDraw.AABB_BIT = 4
Back to top
b2.DebugDraw.CENTER_OF_MASS_BIT
Available since version: Gideros 2011.6
Description:
Value:
b2.DebugDraw.CENTER_OF_MASS_BIT = 16
Back to top
b2.DebugDraw.JOINT_BIT
Available since version: Gideros 2011.6
Description:
Value:
b2.DebugDraw.JOINT_BIT = 2
Back to top
b2.DebugDraw.PAIR_BIT
Available since version: Gideros 2011.6
Description:
Value:
b2.DebugDraw.PAIR_BIT = 8
Back to top
b2.DebugDraw.SHAPE_BIT
Available since version: Gideros 2011.6
Description:
Value:
b2.DebugDraw.SHAPE_BIT = 1
Back to top
Back to top
b2.DistanceJoint:getDampingRatio
Available since version: Gideros 2011.6
Description:
Returns the damping ratio of this distance joint.
Syntax:
b2.DistanceJoint:getDampingRatio()
Back to top
b2.DistanceJoint:getFrequency
Available since version: Gideros 2011.6
Description:
Returns the mass-spring-damper frequency of this distance joint in Hertz.
Syntax:
b2.DistanceJoint:getFrequency()
Back to top
b2.DistanceJoint:getLength
Available since version: Gideros 2011.6
Description:
Returns the length of this distance joint, usually in meters.
Syntax:
b2.DistanceJoint:getLength()
Back to top
b2.DistanceJoint:setDampingRatio
Available since version: Gideros 2011.6
Description:
Sets the damping ratio of this distance joint. 0 = no damping, 1 = critical damping.
Syntax:
b2.DistanceJoint:setDampingRatio(ratio)
Parameters:
- ratio: (number) the damping ratio
Back to top
b2.DistanceJoint:setFrequency
Available since version: Gideros 2011.6
Description:
Sets the mass-spring-damper frequency in Hertz.
Syntax:
b2.DistanceJoint:setFrequency(frequency)
Parameters:
- frequency: (number) the mass-spring-damper frequency in Hertz
Back to top
b2.DistanceJoint:setLength
Available since version: Gideros 2011.6
Description:
Sets the natural length. Manipulating the length can lead to non-physical behavior when the frequency is zero.
Syntax:
b2.DistanceJoint:setLength(length)
Parameters:
- length: (number) the length of this distance joint, usually in meters.
Back to top
Back to top
b2.EdgeShape.new
Available since version: Gideros 2011.6
Description:
Creates a new
b2.EdgeShape instance and optionally sets its 2 vertices.
If this function is called with more than 4 parameters,
b2.EdgeShape instance
is created and its 2 vertices are set. If this function is called without any
paramaters, only
b2.EdgeShape instance is created and you should set the 2
vertices with [[b2.EdgeShape:set]] function.
Syntax:
b2.EdgeShape.new(v1x, v1y, v2x, v2y)
Parameters:
- v1x: (number, optional) - the x coordinate of 1st point of edge
- v1y: (number, optional) - the y coordinate of 1st point of edge
- v2x: (number, optional) - the x coordinate of 2nd point of edge
- v2y: (number, optional) - the y coordinate of 2nd point of edge
Back to top
b2.EdgeShape:set
Available since version: Gideros 2011.6
Description:
Sets the two vertices of this instance.
Syntax:
b2.EdgeShape:set(v1x, v1y, v2x, v2y)
Parameters:
- v1x: (number) - the x coordinate of 1st point of edge
- v1y: (number) - the y coordinate of 1st point of edge
- v2x: (number) - the x coordinate of 2nd point of edge
- v2y: (number) - the y coordinate of 2nd point of edge
Back to top
Back to top
b2.Fixture:getBody
Available since version: Gideros 2011.6
Description:
Returns the parent body of this fixture. This is nil
if the fixture is not attached.
Syntax:
b2.Fixture:getBody()
Back to top
b2.Fixture:getFilterData
Available since version: Gideros 2011.6
Description:
Returns the contact filtering data.
Syntax:
b2.Fixture:getFilterData()
Back to top
b2.Fixture:isSensor
Available since version: Gideros 2011.6
Description:
Is this fixture a sensor (non-solid)?
Syntax:
b2.Fixture:isSensor()
Back to top
b2.Fixture:setFilterData
Available since version: Gideros 2011.6
Description:
Sets the contact filtering data. This will not update contacts until the next time step
when either parent body is active and awake. The filter data definition is given
as a ordinary table. The fields of the filter data table are:
- **categoryBits**: (number) The collision category bits. Normally you would just set one bit.
- **maskBits**: (number) The collision mask bits. This states the categories that this shape would accept for collision.
- **groupIndex**: (number) Collision groups allow a certain group of objects to never collide (negative) or always collide (positive). Zero means no collision group. Non-zero group filtering always wins against the mask bits.
Syntax:
b2.Fixture:setFilterData(filterData)
Parameters:
Back to top
b2.Fixture:setSensor
Available since version: Gideros 2011.6
Description:
Sets if this fixture is a sensor.
Syntax:
b2.Fixture:setSensor(sensor)
Parameters:
Back to top
Back to top
b2.FrictionJoint:getMaxForce
Available since version: Gideros 2011.6
Description:
Returns the maximum friction force in N.
Syntax:
b2.FrictionJoint:getMaxForce()
Back to top
b2.FrictionJoint:getMaxTorque
Available since version: Gideros 2011.6
Description:
Returns the maximum friction torque in N*m.
Syntax:
b2.FrictionJoint:getMaxTorque()
Back to top
b2.FrictionJoint:setMaxForce
Available since version: Gideros 2011.6
Description:
Sets the maximum friction force in N.
Syntax:
b2.FrictionJoint:setMaxForce(force)
Parameters:
- force: (number) the maximum friction force in N
Back to top
b2.FrictionJoint:setMaxTorque
Available since version: Gideros 2011.6
Description:
Sets the maximum friction torque in N*m.
Syntax:
b2.FrictionJoint:setMaxTorque(torque)
Parameters:
- torque: (number) the maximum friction torque in N*m
Back to top
Back to top
b2.GearJoint:getRatio
Available since version: Gideros 2011.6
Description:
Returns the gear ratio.
Syntax:
b2.GearJoint:getRatio()
Back to top
b2.GearJoint:setRatio
Available since version: Gideros 2011.6
Description:
Sets the gear ratio.
Syntax:
b2.GearJoint:setRatio(ratio)
Parameters:
- ratio: (number) the gear ratio
Back to top
b2.Joint
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
b2.Joint class is the base joint class. Joints are used to constraint two bodies together in various fashions. Some joints also feature limits and motors.
Back to top
b2.Joint:getAnchorA
Available since version: Gideros 2011.6
Description:
Returns the anchor point on bodyA in world coordinates.
Syntax:
b2.Joint:getAnchorA()
Back to top
b2.Joint:getAnchorB
Available since version: Gideros 2011.6
Description:
Returns the anchor point on bodyB in world coordinates.
Syntax:
b2.Joint:getAnchorB()
Back to top
b2.Joint:getBodyA
Available since version: Gideros 2011.6
Description:
Returns the first body attached to this joint.
Syntax:
b2.Joint:getBodyA()
Back to top
b2.Joint:getBodyB
Available since version: Gideros 2011.6
Description:
Returns the second body attached to this joint.
Syntax:
b2.Joint:getBodyB()
Back to top
b2.Joint:getReactionForce
Available since version: Gideros 2011.6
Description:
Returns the reaction force on bodyB at the joint anchor in Newtons.
Syntax:
b2.Joint:getReactionForce(inv_dt)
Parameters:
Back to top
b2.Joint:getReactionTorque
Available since version: Gideros 2011.6
Description:
Returns the reaction torque on bodyB in N*m.
Syntax:
b2.Joint:getReactionTorque(inv_dt)
Parameters:
Back to top
b2.Joint:getType
Available since version: Gideros 2011.6
Description:
Returns the type of the concrete joint. The return value can be one of the b2.REVOLUTE_JOINT
, b2.PRISMATIC_JOINT
, b2.DISTANCE_JOINT
, b2.PULLEY_JOINT
,
b2,MOUSE_JOINT
, b2.GEAR_JOINT
, b2.LINE_JOINT
, b2.WELD_JOINT
, b2.FRICTION_JOINT
, b2.ROPE_JOINT
.
Syntax:
b2.Joint:getType()
Back to top
b2.Joint:isActive
Available since version: Gideros 2011.6
Description:
Short-cut function to determine if either body is inactive.
Syntax:
b2.Joint:isActive()
Back to top
Back to top
b2.MouseJoint:getDampingRatio
Available since version: Gideros 2011.6
Description:
Returns the damping ratio. 0 = no damping, 1 = critical damping.
Syntax:
b2.MouseJoint:getDampingRatio()
Back to top
b2.MouseJoint:getFrequency
Available since version: Gideros 2011.6
Description:
Returns the response speed in Hertz.
Syntax:
b2.MouseJoint:getFrequency()
Back to top
b2.MouseJoint:getMaxForce
Available since version: Gideros 2011.6
Description:
Returns the maximum force in Newtons.
Syntax:
b2.MouseJoint:getMaxForce()
Back to top
b2.MouseJoint:getTarget
Available since version: Gideros 2011.6
Description:
Returns the x and y coordinates of the target point.
Syntax:
b2.MouseJoint:getTarget()
Back to top
b2.MouseJoint:setDampingRatio
Available since version: Gideros 2011.6
Description:
Sets the damping ratio. 0 = no damping, 1 = critical damping.
Syntax:
b2.MouseJoint:setDampingRatio(ratio)
Parameters:
- ratio: (number) the damping ratio
Back to top
b2.MouseJoint:setFrequency
Available since version: Gideros 2011.6
Description:
Sets the response speed in Hertz.
Syntax:
b2.MouseJoint:setFrequency(frequency)
Parameters:
- frequency: (number) the response speed in Hertz
Back to top
b2.MouseJoint:setMaxForce
Available since version: Gideros 2011.6
Description:
Sets the maximum force in Newtons.
Syntax:
b2.MouseJoint:setMaxForce(force)
Parameters:
- force: (number) the maximum force in Newtons
Back to top
b2.MouseJoint:setTarget
Available since version: Gideros 2011.6
Description:
Updates the target point.
Syntax:
b2.MouseJoint:setTarget(x, y)
Parameters:
- x: (number) x coordinate of the target point
- y: (number) y coordinate of the target point
Back to top
Back to top
b2.PolygonShape.new
Available since version: Gideros 2011.6
Description:
Syntax:
b2.PolygonShape.new()
Back to top
b2.PolygonShape:set
Available since version: Gideros 2011.6
Description:
Copy vertices. This assumes the vertices define a convex polygon. It is assumed that the exterior is the the right of each edge.
Syntax:
b2.PolygonShape:set(vertices)
Parameters:
- vertices: A list of numbers that contains the x, y coordinates of the vertices sequentially
Examples:
local polygonShape = b2.PolygonShape.new()
polygonShape:set(1,4, 2,6, 3,7)
Back to top
b2.PolygonShape:setAsBox
Available since version: Gideros 2011.6
Description:
Build vertices to represent an oriented box.
Syntax:
b2.PolygonShape:setAsBox(hx, hy, centerx, centery, angle)
Parameters:
- hx: (number) the half-width
- hy: (number) the half-heigh
- centerx: (number, default = 0) the x coordinate of the center of the box in local coordinates
- centery: (number, default = 0) the y coordinate of the center of the box in local coordinates
- angle: (number, default = 0) the rotation of the box in local coordinates
Back to top
Back to top
b2.PrismaticJoint:enableLimit
Available since version: Gideros 2011.6
Description:
Enables or disables the joint limit.
Syntax:
b2.PrismaticJoint:enableLimit(flag)
Parameters:
- flag: (boolean) enable flag of joint limit
Back to top
b2.PrismaticJoint:enableMotor
Available since version: Gideros 2011.6
Description:
Enables or disables the joint motor.
Syntax:
b2.PrismaticJoint:enableMotor(flag)
Parameters:
- flag: (boolean) enable flag of joint motor
Back to top
b2.PrismaticJoint:getJointSpeed
Available since version: Gideros 2011.6
Description:
Returns the current joint translation speed, usually in meters per second.
Syntax:
b2.PrismaticJoint:getJointSpeed()
Back to top
b2.PrismaticJoint:getJointTranslation
Available since version: Gideros 2011.6
Description:
Returns the current joint translation, usually in meters.
Syntax:
b2.PrismaticJoint:getJointTranslation()
Back to top
b2.PrismaticJoint:getLimits
Available since version: Gideros 2011.6
Description:
Returns the lower and upper joint limit, usually in meters.
Syntax:
b2.PrismaticJoint:getLimits()
Back to top
b2.PrismaticJoint:getMotorSpeed
Available since version: Gideros 2011.6
Description:
Returns the motor speed in meters per second.
Syntax:
b2.PrismaticJoint:getMotorSpeed()
Back to top
b2.PrismaticJoint:isLimitEnabled
Available since version: Gideros 2011.6
Description:
Is the joint limit enabled?
Syntax:
b2.PrismaticJoint:isLimitEnabled()
Back to top
b2.PrismaticJoint:isMotorEnabled
Available since version: Gideros 2011.6
Description:
Is the joint motor enabled?
Syntax:
b2.PrismaticJoint:isMotorEnabled()
Back to top
b2.PrismaticJoint:setLimits
Available since version: Gideros 2011.6
Description:
Sets the joint limits, usually in meters.
Syntax:
b2.PrismaticJoint:setLimits(lower, upper)
Parameters:
- lower: (number) lower joint limit in meters
- upper: (number) upper joint limit in meters
Back to top
b2.PrismaticJoint:setMaxMotorForce
Available since version: Gideros 2011.6
Description:
Sets the maximum motor force, usually in N.
Syntax:
b2.PrismaticJoint:setMaxMotorForce(force)
Parameters:
- force: (number) the maximum motor force, usually in N.
Back to top
b2.PrismaticJoint:setMotorSpeed
Available since version: Gideros 2011.6
Description:
Sets the motor speed in meters per second.
Syntax:
b2.PrismaticJoint:setMotorSpeed(speed)
Parameters:
- speed: (number) motor speed in meters per second
Back to top
b2.RevoluteJoint:getMotorForce
Available since version: Gideros 2011.6
Description:
Returns the current motor force given the inverse time step, usually in N.
Syntax:
b2.RevoluteJoint:getMotorForce(inv_dt)
Parameters:
Back to top
Back to top
b2.PulleyJoint:getGroundAnchorA
Available since version: Gideros 2011.6
Description:
Returns the x and y coordinates of the first ground anchor.
Syntax:
b2.PulleyJoint:getGroundAnchorA()
Back to top
b2.PulleyJoint:getGroundAnchorB
Available since version: Gideros 2011.6
Description:
Returns the x and y coordinates of the second ground anchor.
Syntax:
b2.PulleyJoint:getGroundAnchorB()
Back to top
b2.PulleyJoint:getLengthA
Available since version: Gideros 2011.6
Description:
Returns the current length of the segment attached to bodyA.
Syntax:
b2.PulleyJoint:getLengthA()
Back to top
b2.PulleyJoint:getLengthB
Available since version: Gideros 2011.6
Description:
Returns the current length of the segment attached to bodyB.
Syntax:
b2.PulleyJoint:getLengthB()
Back to top
b2.PulleyJoint:getRatio
Available since version: Gideros 2011.6
Description:
Returns the pulley ratio.
Syntax:
b2.PulleyJoint:getRatio()
Back to top
Back to top
b2.RevoluteJoint:enableLimit
Available since version: Gideros 2011.6
Description:
Enables or disables the joint limit.
Syntax:
b2.RevoluteJoint:enableLimit(flag)
Parameters:
- flag: (boolean) enable flag of joint limit
Back to top
b2.RevoluteJoint:enableMotor
Available since version: Gideros 2011.6
Description:
Enables or disables the joint motor.
Syntax:
b2.RevoluteJoint:enableMotor(flag)
Parameters:
- flag: (boolean) enable flag of joint motor
Back to top
b2.RevoluteJoint:getJointAngle
Available since version: Gideros 2011.6
Description:
Returns the current joint angle in radians.
Syntax:
b2.RevoluteJoint:getJointAngle()
Back to top
b2.RevoluteJoint:getJointSpeed
Available since version: Gideros 2011.6
Description:
Returns the current joint angle speed in radians per second.
Syntax:
b2.RevoluteJoint:getJointSpeed()
Back to top
b2.RevoluteJoint:getLimits
Available since version: Gideros 2011.6
Description:
Returns the lower and upper joint limit in radians.
Syntax:
b2.RevoluteJoint:getLimits()
Back to top
b2.RevoluteJoint:getMotorSpeed
Available since version: Gideros 2011.6
Description:
Returns the motor speed in radians per second.
Syntax:
b2.RevoluteJoint:getMotorSpeed()
Back to top
b2.RevoluteJoint:getMotorTorque
Available since version: Gideros 2011.6
Description:
Returns the current motor torque given the inverse time step. Unit is N*m.
Syntax:
b2.RevoluteJoint:getMotorTorque(inv_dt)
Parameters:
Back to top
b2.RevoluteJoint:isLimitEnabled
Available since version: Gideros 2011.6
Description:
Is the joint limit enabled?
Syntax:
b2.RevoluteJoint:isLimitEnabled()
Back to top
b2.RevoluteJoint:isMotorEnabled
Available since version: Gideros 2011.6
Description:
Is the joint motor enabled?
Syntax:
b2.RevoluteJoint:isMotorEnabled()
Back to top
b2.RevoluteJoint:setLimits
Available since version: Gideros 2011.6
Description:
Sets the joint limits in radians.
Syntax:
b2.RevoluteJoint:setLimits(lower, upper)
Parameters:
- lower: (number) lower joint limit in radians
- upper: (number) upper joint limit in radians
Back to top
b2.RevoluteJoint:setMaxMotorTorque
Available since version: Gideros 2011.6
Description:
Sets the maximum motor torque, usually in N-m.
Syntax:
b2.RevoluteJoint:setMaxMotorTorque(torque)
Parameters:
- torque: (number) the maximum motor torque, usually in N-m
Back to top
b2.RevoluteJoint:setMotorSpeed
Available since version: Gideros 2011.6
Description:
Sets the motor speed in radians per second.
Syntax:
b2.RevoluteJoint:setMotorSpeed(speed)
Parameters:
- speed: (number) motor speed in radians per second
Back to top
Back to top
b2.RopeJoint:getMaxLength
Available since version: Gideros 2012.09.3
Description:
Returns the maximum length of the rope.
Syntax:
b2.RopeJoint:getMaxLength()
Back to top
b2.RopeJoint:setMaxLength
Available since version: Gideros 2012.09.3
Description:
Sets the maximum length of the rope.
Syntax:
b2.RopeJoint:setMaxLength(maxLength)
Parameters:
Back to top
b2.Shape
Supported platforms:
Available since version: Gideros 2011.6
Description:
A shape is used for collision detection. It is the base class of [[b2.CircleShape]] and [[b2.PolygonShape]] classes.
You can not create a
b2.Shape instance directly, but instead you create [[b2.CircleShape]] and [[b2.PolygonShape]] instances.
Back to top
Back to top
b2.WeldJoint:getDampingRatio
Available since version: Gideros 2011.6
Description:
Returns damping ratio.
Syntax:
b2.WeldJoint:getDampingRatio()
Back to top
b2.WeldJoint:getFrequency
Available since version: Gideros 2011.6
Description:
Returns frequency in Hz.
Syntax:
b2.WeldJoint:getFrequency()
Back to top
b2.WeldJoint:setDampingRatio
Available since version: Gideros 2011.6
Description:
Sets damping ratio.
Syntax:
b2.WeldJoint:setDampingRatio(damping)
Parameters:
- damping: (number) damping ratio
Back to top
b2.WeldJoint:setFrequency
Available since version: Gideros 2011.6
Description:
Sets frequency in Hz.
Syntax:
b2.WeldJoint:setFrequency(frequency)
Parameters:
- frequency: (number) frequency in Hz
Back to top
Back to top
b2.WheelJoint:enableMotor
Available since version: Gideros 2011.6
Description:
Enables or disables the joint motor.
Syntax:
b2.WheelJoint:enableMotor(flag)
Parameters:
- flag: (boolean) enable flag of joint motor
Back to top
b2.WheelJoint:getJointSpeed
Available since version: Gideros 2011.6
Description:
Returns the current joint translation speed in meters per second.
Syntax:
b2.WheelJoint:getJointSpeed()
Back to top
b2.WheelJoint:getJointTranslation
Available since version: Gideros 2011.6
Description:
Returns the current joint translation in meters.
Syntax:
b2.WheelJoint:getJointTranslation()
Back to top
b2.WheelJoint:getMaxMotorTorque
Available since version: Gideros 2011.6
Description:
Returns the maximum motor torque in N*m.
Syntax:
b2.WheelJoint:getMaxMotorTorque()
Back to top
b2.WheelJoint:getMotorSpeed
Available since version: Gideros 2011.6
Description:
Returns the motor speed in radians per second.
Syntax:
b2.WheelJoint:getMotorSpeed()
Back to top
b2.WheelJoint:getSpringDampingRatio
Available since version: Gideros 2011.6
Description:
Returns the spring damping ratio.
Syntax:
b2.WheelJoint:getSpringDampingRatio()
Back to top
b2.WheelJoint:getSpringFrequencyHz
Available since version: Gideros 2011.6
Description:
Returns the spring frequency in hertz.
Syntax:
b2.WheelJoint:getSpringFrequencyHz()
Back to top
b2.WheelJoint:isMotorEnabled
Available since version: Gideros 2011.6
Description:
Is the joint motor enabled?
Syntax:
b2.WheelJoint:isMotorEnabled()
Back to top
b2.WheelJoint:setMaxMotorTorque
Available since version: Gideros 2011.6
Description:
Sets the maximum motor torque in N*m.
Syntax:
b2.WheelJoint:setMaxMotorTorque(torque)
Parameters:
- torque: (number) the maximum motor torque in N-m
Back to top
b2.WheelJoint:setMotorSpeed
Available since version: Gideros 2011.6
Description:
Sets the motor speed in radians per second.
Syntax:
b2.WheelJoint:setMotorSpeed(speed)
Parameters:
- speed: (number) motor speed in radians per second
Back to top
b2.WheelJoint:setSpringDampingRatio
Available since version: Gideros 2011.6
Description:
Sets the spring damping ratio.
Syntax:
b2.WheelJoint:setSpringDampingRatio(damping)
Parameters:
- damping: (number) damping ratio
Back to top
b2.WheelJoint:setSpringFrequencyHz
Available since version: Gideros 2011.6
Description:
Sets the spring frequency in hertz. Setting the frequency to zero disables the spring.
Syntax:
b2.WheelJoint:setSpringFrequencyHz(frequency)
Parameters:
- frequency: (number) spring frequency in hertz
Back to top
b2.World
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
b2.World class inherits from the following class:
EventDispatcher.
The
b2.World class manages all physics entities and dynamic simulation. It is possible to create and manage more than one
b2.World instance.
Back to top
b2.World.new
Available since version: Gideros 2011.6
Description:
Creates a new
b2.World object. You can create more then one
b2.World object to manage independent worlds.
Syntax:
b2.World.new(gravityx, gravityy, doSleep)
Parameters:
- gravityx: (number) the x component the gravity
- gravityy: (number) the y component the gravity
- doSleep: (boolean, default = true) improve performance by not simulating inactive bodies
Back to top
b2.World:clearForces
Available since version: Gideros 2011.6
Description:
Call this after you are done with time steps to clear the forces. You normally call this after each call to b2.World:step
,
unless you are performing sub-steps. By default, forces will be automatically cleared, so you don't need to call this function.
Syntax:
b2.World:clearForces()
Back to top
b2.World:createBody
Available since version: Gideros 2011.6
Description:
Creates a rigid body given a definition. The body definition is given as an ordinary table. The fields of the body definition table are:
- **type**: (number) The body type:
b2.STATIC_BODY
, b2.KINEMATIC_BODY
, or b2.DYNAMIC_BODY
. Note: if a dynamic body would have zero mass, the mass is set to one.
- **position**: (table) The world position of the body (see the example below to understand how this table is set). Avoid creating bodies at the origin since this can lead to many overlapping shapes.
- **angle**: (number) The world angle of the body in radians.
- **linearVelocity**: (table) The linear velocity of the body's origin in world co-ordinates (see the example below to understand how this table is set).
- **angularVelocity**: (number) The angular velocity of the body.
- **linearDamping**: (number) Linear damping is use to reduce the linear velocity. The damping parameter can be larger than 1.0 but the damping effect becomes sensitive to the time step when the damping parameter is large.
- **angularDamping**: (number) Angular damping is use to reduce the angular velocity. The damping parameter can be larger than 1.0 but the damping effect becomes sensitive to the time step when the damping parameter is large.
- **allowSleep**: (boolean) Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.
- **awake**: (boolean) Is this body initially awake or sleeping?
- **fixedRotation**: (boolean) Should this body be prevented from rotating? Useful for characters.
- **bullet**: (boolean) Is this a fast moving body that should be prevented from tunneling through other moving bodies? Note that all bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies. **Warning:** You should use this flag sparingly since it increases processing time.
- **active**: (boolean) Does this body start out active?
- **gravityScale**: (number) Scale the gravity applied to this body.
The unset fields gets default values.
- *Warning:** This function is locked during callbacks.
Syntax:
b2.World:createBody(bodyDef)
Parameters:
Examples:
local body = world:createBody{
type = b2.STATIC_BODY,
position = {x=0, y=0.5},
angle = math.pi/4,
linearVelocity = {x=0.1, y=0.2},
}
Back to top
b2.World:createJoint
Available since version: Gideros 2011.6
Description:
Creates a joint given a definition. All 10 types of joints is created by using this function:
Revolute Joint
Revolute joint definition. This requires defining an anchor point where the bodies are joined. The definition uses
local anchor points so that the initial configuration can violate the constraint slightly. You also need to specify the
initial relative angle for joint limits. This helps when saving and loading a game. The local anchor points are measured from
the body's origin rather than the center of mass because:
1. you might not know where the center of mass will be.
2. if you add/remove shapes from a body
and recompute the mass, the joints will be broken.
- **type**: (number) b2.REVOLUTE_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **localAnchorA**: (table) The local anchor point relative to bodyA's origin.
- **localAnchorB**: (table) The local anchor point relative to bodyB's origin.
- **referenceAngle**: (number) The bodyB angle minus bodyA angle in the reference state (radians).
- **enableLimit**: (boolean) A flag to enable joint limits.
- **lowerAngle**: (number) The lower angle for the joint limit (radians).
- **upperAngle**: (number) The upper angle for the joint limit (radians).
- **enableMotor**: (boolean) A flag to enable the joint motor.
- **motorSpeed**: (number) The desired motor speed. Usually in radians per second.
- **maxMotorTorque**: (number) The maximum motor torque used to achieve the desired motor speed. Usually in N-m.
Also, you can use [[b2.createRevoluteJointDef]] function to create a revolute joint definiton table easier.
Prismatic Joint
Prismatic joint definition. This requires defining a line of motion using an axis and an anchor point. The definition uses
local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is
zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.
- **type**: (number) b2.PRISMATIC_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **localAnchorA**: (table) The local anchor point relative to bodyA's origin.
- **localAnchorB**: (table) The local anchor point relative to bodyB's origin.
- **localAxisA**: (table) The local translation axis in bodyA.
- **referenceAngle**: (number) The body2 angle minus body1 angle in the reference state (radians).
- **enableLimit**: (boolean) A flag to enable joint limits.
- **lowerTranslation**: (number) The lower translation limit, usually in meters.
- **upperTranslation**: (number) The upper translation limit, usually in meters.
- **enableMotor**: (boolean) A flag to enable the joint motor.
- **maxMotorForce**: (number) The maximum motor torque, usually in N-m.
- **motorSpeed**: (number) The desired motor speed in radians per second.
Also, you can use [[b2.createPrismaticJointDef]] function to create a prismatic joint definiton table easier.
Distance Joint
Distance joint definition. This requires defining an anchor point on both bodies and the non-zero length of the distance joint.
The definition uses local anchor points so that the initial configuration can violate the constraint slightly.
This helps when saving and loading a game.
- **type**: (number) b2.DISTANCE_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **localAnchorA**: (table) The local anchor point relative to bodyA's origin.
- **localAnchorB**: (table) The local anchor point relative to bodyB's origin.
- **length**: (number) The natural length between the anchor points. Do not use a zero or short length.
- **frequencyHz**: (number) The mass-spring-damper frequency in Hertz.
- **dampingRatio**: (number) The damping ratio. 0 = no damping, 1 = critical damping.
Also, you can use [[b2.createDistanceJointDef]] function to create a distance joint definiton table easier.
Pulley Joint
Pulley joint definition. This requires two ground anchors, two dynamic body anchor points, max lengths for each side, and a pulley ratio.
- **type**: (number) b2.PULLEY_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **groundAnchorA**: (table) The first ground anchor in world coordinates. This point never moves.
- **groundAnchorB**: (table) The second ground anchor in world coordinates. This point never moves.
- **localAnchorA**: (table) The local anchor point relative to bodyA's origin.
- **localAnchorB**: (table) The local anchor point relative to bodyB's origin.
- **lengthA**: (number) The a reference length for the segment attached to bodyA.
- **lengthB**: (number) The a reference length for the segment attached to bodyB.
- **ratio**: (number) The pulley ratio, used to simulate a block-and-tackle.
Also, you can use [[b2.createPulleyJointDef]] function to create a pulley joint definiton table easier.
Mouse Joint
Mouse joint definition. This requires a world target point, tuning parameters, and the time step.
- **type**: (number) b2.MOUSE_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **target**: (table) The initial world target point. This is assumed to coincide with the body anchor initially.
- **maxForce**: (number) The maximum constraint force that can be exerted to move the candidate body. Usually you will express as some multiple of the weight (multiplier * mass * gravity).
- **frequencyHz**: (number) The response speed.
- **dampingRatio**: (number) The damping ratio. 0 = no damping, 1 = critical damping.
Also, you can use [[b2.createMouseJointDef]] function to create a mouse joint definiton table easier.
Gear Joint
Gear joint definition. This definition requires two existing revolute or prismatic joints (any combination will work). The provided joints
must attach a dynamic body to a static body.
- **type**: (number) b2.GEAR_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **joint1**: (b2.Joint) The first revolute/prismatic joint attached to the gear joint.
- **joint2**: (b2.Joint) The second revolute/prismatic joint attached to the gear joint.
- **ratio**: (number) The gear ratio.
Also, you can use [[b2.createGearJointDef]] function to create a gear joint definiton table easier.
Wheel Joint
Wheel joint definition. This requires defining a line of motion using an axis and an anchor point.
The definition uses local anchor points and a local axis so that the initial configuration can violate
the constraint slightly. The joint translation is zero when the local anchor points coincide in world space.
Using local anchors and a local axis helps when saving and loading a game.
- **type**: (number) b2.WHEEL_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **localAnchorA**: (table) The local anchor point relative to bodyA's origin.
- **localAnchorB**: (table) The local anchor point relative to bodyB's origin.
- **localAxisA**: (table) The local translation axis in bodyA.
- **enableMotor**: (boolean) A flag to enable the joint motor.
- **maxMotorTorque**: (number) The maximum motor torque, usually in N-m.
- **motorSpeed**: (number) The desired motor speed in radians per second.
- **frequencyHz**: (number) Suspension frequency, zero indicates no suspension.
- **dampingRatio**: (number) Suspension damping ratio, one indicates critical damping.
Also, you can use [[b2.createWheelJointDef]] function to create a wheel joint definiton table easier.
Weld Joint
Weld joint definition. You need to specify local anchor points where they are attached and the relative
body angle. The position of the anchor points is important for computing the reaction torque.
- **type**: (number) b2.WELD_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **localAnchorA**: (table) The local anchor point relative to bodyA's origin.
- **localAnchorB**: (table) The local anchor point relative to bodyB's origin.
- **referenceAngle**: (number) The bodyB angle minus bodyA angle in the reference state (radians).
Also, you can use [[b2.createWeldJointDef]] function to create a weld joint definiton table easier.
Friction Joint
Friction joint definition.
- **type**: (number) b2.LINE_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **localAnchorA**: (table) The local anchor point relative to bodyA's origin.
- **localAnchorB**: (table) The local anchor point relative to bodyB's origin.
- **maxForce**: (number) The maximum friction force in N.
- **maxTorque**: (number) The maximum friction torque in N-m.
Rope Joint
Rope joint definition. This requires two body anchor points and a maximum length.
- **type**: (number) b2.ROPE_JOINT
- **bodyA**: (b2.Body) The first attached body.
- **bodyB**: (b2.Body) The second attached body.
- **collideConnected**: (boolean) Set this flag to true if the attached bodies should collide.
- **localAnchorA**: (table) The local anchor point relative to bodyA's origin.
- **localAnchorB**: (table) The local anchor point relative to bodyB's origin.
- **maxLength**: (number) The maximum length of the rope.
Also, you can use [[b2.createRopeJointDef]] function to create a rope joint definiton table easier.
Syntax:
b2.World:createJoint(jointDef)
Parameters:
Back to top
b2.World:destroyBody
Available since version: Gideros 2011.6
Description:
Destroys a rigid body. This function is locked during callbacks.
- This automatically deletes all associated shapes and joints.
- This function is locked during callbacks.
Syntax:
b2.World:destroyBody(body)
Parameters:
- body: (b2.Body) body to be destroyed
Back to top
b2.World:destroyJoint
Available since version: Gideros 2011.6
Description:
Destroy a joint. This may cause the connected bodies to begin colliding.
- *Warning:** This function is locked during callbacks.
Syntax:
b2.World:destroyJoint(joint)
Parameters:
- joint: (b2.Joint) joint to be destroyed
Back to top
b2.World:getGravity
Available since version: Gideros 2011.6
Description:
Returns the gravity vector.
Syntax:
b2.World:getGravity()
Back to top
b2.World:queryAABB
Available since version: Gideros 2011.6
Description:
Query the world for all fixtures that potentially overlap the provided AABB.
Syntax:
b2.World:queryAABB(lowerx, lowery, upperx, uppery)
Parameters:
- lowerx: (number) the lower x coordinate of the query box
- lowery: (number) the lower y coordinate of the query box
- upperx: (number) the upper x coordinate of the query box
- uppery: (number) the upper y coordinate of the query box
Back to top
b2.World:rayCast
Available since version: Gideros 2011.6
Description:
Ray-cast the world for all fixtures in the path of the ray. Your callback controls whether you get the closest point, any point, or n-points. The ray-cast ignores shapes that contain the starting point.
Listener function is called for each fixture found in the query and accepts 6 parameters (7 if data parameter is provided):
1. the fixture hit by the ray
2. the x coordinate of the point of initial intersection
3. the y coordinate of the point of initial intersection
4. the x coordinate of the normal vector at the point of intersection
5. the y coordinate of the normal vector at the point of intersection
6. fraction
You control how the ray cast proceeds by returning a number:
- return no value or -1: ignore this fixture and continue
- return 0: terminate the ray cast
- return fraction: clip the ray to this point
- return 1: don't clip the ray and continue
Syntax:
b2.World:rayCast(x1, y1, x2, y2, listener [, data])
Parameters:
- x1: (number) the x coordinate of the ray starting point
- y1: (number) the y coordinate of the ray starting point
- x2: (number) the x coordinate of the ray ending point
- y2: (number) the y coordinate of the ray ending point
- listener: (function) the listener function that processes the results
- data: an optional data parameter that is passed as a first argument to the listener function
Back to top
b2.World:setDebugDraw
Available since version: Gideros 2011.6
Description:
Registers a b2.DebugDraw instance for debug drawing.
Syntax:
b2.World:setDebugDraw()
Back to top
b2.World:setGravity
Available since version: Gideros 2011.6
Description:
Sets the gravity vector.
Syntax:
b2.World:setGravity(gravityx, gravityy)
Parameters:
- gravityx: (number) the x component the gravity
- gravityy: (number) the y component the gravity
Back to top
b2.World:step
Available since version: Gideros 2011.6
Description:
Take a time step. This performs collision detection, integration, and constraint solution.
Syntax:
b2.World:step(timeStep, velocityIterations, positionIterations)
Parameters:
- timeStep: (number) the amount of time to simulate, this should not vary
- velocityIterations: (number) for the velocity constraint solver
- positionIterations: (number) for the position constraint solver
Back to top
Back to top
Back to top
Event.POST_SOLVE
Available since version: Gideros 2011.6
Description:
This event is dispatched after the reaction between box2d objects and contains some additional information which has been calculated, like, maximal impulse of collision in e.maxImpulse
.
Value:
Event.POST_SOLVE = "postSolve"
Event properties:
- contact: (b2.Contact) Contains instance of `b2.Contact` holding information about this collision
- fixtureA: (b2.Fixture) Contains instance of `b2.Fixture` of first colliding body
- fixtureB: (b2.Fixture) Contains instance of `b2.Fixture` of second colliding body
- maxImpulse: (number) The maximal impulse (strength) of collision
Back to top
Event.PRE_SOLVE
Available since version: Gideros 2011.6
Description:
This event is usually dispatched after Event.BEGIN_CONTACT
and can be dispatched multiple times on each reaction between objects.
Usually in this event you can cancel or modify collisions in other ways using event.contact
object.
Value:
Event.PRE_SOLVE = "preSolve"
Event properties:
- contact: (b2.Contact) Contains instance of `b2.Contact` holding information about this collision
- fixtureA: (b2.Fixture) Contains instance of `b2.Fixture` of first colliding body
- fixtureB: (b2.Fixture) Contains instance of `b2.Fixture` of second colliding body
Back to top
Back to top
bit.arshift
Available since version: Gideros 2013.09
Description:
Returns the bitwise arithmetic right-shift by the number of bits given by the second argument.
Syntax:
bit.arshift(x, n)
Parameters:
- x: (number) number to shift
- n: (number) amount of bits to shift
Back to top
bit.band
Available since version: Gideros 2013.09
Description:
Returns the bitwise and of its argument.
Syntax:
bit.band(x1 [, x2])
Parameters:
- x1: (number) first number for and operation
- x2: (number) second and more numbers can be provided for and operation
Back to top
bit.bnot
Available since version: Gideros 2013.09
Description:
Returns the bitwise not of its argument.
Syntax:
bit.bnot(x)
Parameters:
- x: (number) number to which to apply bitwise not
Back to top
bit.bor
Available since version: Gideros 2013.09
Description:
Returns the bitwise or of its argument.
Syntax:
bit.bor(x1 [, x2])
Parameters:
- x1: (number) first number for or operation
- x2: (number) second and more numbers can be provided for or operation
Back to top
bit.bswap
Available since version: Gideros 2013.09
Description:
Swaps the bytes of its argument and returns it. This can be used to convert little-endian 32 bit numbers to big-endian 32 bit numbers or vice versa.
Syntax:
bit.bswap(x)
Parameters:
- x: (number) number to swap
Back to top
bit.bxor
Available since version: Gideros 2013.09
Description:
Returns the bitwise xor of its argument.
Syntax:
bit.bxor(x1 [, x2])
Parameters:
- x1: (number) first number for xor operation
- x2: (number) second and more numbers can be provided for xor operation
Back to top
bit.lshift
Available since version: Gideros 2013.09
Description:
Returns the bitwise logical left-shift by the number of bits given by the second argument.
Syntax:
bit.lshift(x, n)
Parameters:
- x: (number) number to shift
- n: (number) amount of bits to shift
Back to top
bit.rol
Available since version: Gideros 2013.09
Description:
Returns the bitwise left rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
Syntax:
bit.rol(x, n)
Parameters:
- x: (number) number to rotate
- n: (number) amount of bits to rotate
Back to top
bit.ror
Available since version: Gideros 2013.09
Description:
Returns the bitwise right rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
Syntax:
bit.ror(x, n)
Parameters:
- x: (number) number to rotate
- n: (number) amount of bits to rotate
Back to top
bit.rshift
Available since version: Gideros 2013.09
Description:
Returns the bitwise logical right-shift by the number of bits given by the second argument.
Syntax:
bit.rshift(x, n)
Parameters:
- x: (number) number to shift
- n: (number) amount of bits to shift
Back to top
bit.tobit
Available since version: Gideros 2013.09
Description:
Normalizes a number to the numeric range for bit operations and returns it. This function is usually not needed since all bit operations already normalize all of their input arguments.
Syntax:
bit.tobit(x)
Parameters:
- x: (number) number which range to normalize
Back to top
bit.tohex
Available since version: Gideros 2013.09
Description:
Converts its first argument to a hex string. The number of hex digits is given by the absolute value of the optional second argument. Positive numbers between 1 and 8 generate lowercase hex digits. Negative numbers generate uppercase hex digits. Only the least-significant 4*|n| bits are used. The default is to generate 8 lowercase hex digits.
Syntax:
bit.tohex(x [, n])
Parameters:
- x: (number) number to convert to hex string
- n: (number) number of hex digits to convert
Back to top
Bitmap
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
Bitmap class is used to display texture related objects in the scene tree. It is possible to create Bitmap object from
TextureBase or
TextureRegion instances.
Back to top
Bitmap.new
Available since version: Gideros 2011.6
Description:
Syntax:
Bitmap.new(texture)
Parameters:
- texture: (TextureBase or TextureRegion)
Examples:
local texture = Texture.new("image.png")
local region = TextureRegion.new(texture, 0, 0, 100, 50)
local bitmap1 = Bitmap.new(texture)
local bitmap2 = Bitmap.new(region)
stage:addChild(bitmap1)
stage:addChild(bitmap2)
Back to top
Bitmap:getAnchorPoint
Available since version: Gideros 2011.6
Description:
Returns the x and y coordinates of the anchor point.
Syntax:
Bitmap:getAnchorPoint()
Back to top
Bitmap:setAnchorPoint
Available since version: Gideros 2011.6
Description:
Sets the anchor point of
Bitmap object.
Each
Bitmap object has an anchor point that affects the positioning of the texture displayed. By modifying the anchor point, you change the origin of the texture. For example, setting the anchor point to (0.5, 0.5) moves the center of the texture to the origin. If you set the anchor point to (1, 1) instead, the bottom-right corner of the texture will be the origin. The default value of anchor point is (0, 0) which means top-left of the texture is the origin by default.
Syntax:
Bitmap:setAnchorPoint(x, y)
Parameters:
- x: (number) The x coordinate of anchor point. Usually between [0, 1].
- y: (number) The y coordinate of anchor point. Usually between [0, 1].
Back to top
Bitmap:setTexture
Available since version: Gideros 2012.08.2
Description:
Sets the texture.
Syntax:
Bitmap:setTexture(texture)
Parameters:
Back to top
Bitmap:setTextureRegion
Available since version: Gideros 2012.08.2
Description:
Sets the texture region.
Syntax:
Bitmap:setTextureRegion(textureRegion)
Parameters:
- textureRegion: (TextureRegion)
Back to top
Core
Supported platforms:
Available since version: Gideros 2012.2
Description:
Gideros core functions
Back to top
Core.class
Available since version: Gideros 2012.2
Description:
Creates and returns new Gideros class
Syntax:
Core.class([base])
Parameters:
- base: (GiderosClass) Gideros class from which to inherit
Back to top
Back to top
coroutine.create
Available since version: Gideros 2011.6
Description:
creates coroutine from function f, returns coroutine
Syntax:
coroutine.create(f)
Parameters:
Back to top
coroutine.resume
Available since version: Gideros 2011.6
Description:
continues execution of co, returns bool status plus any values
Syntax:
coroutine.resume(co, val1, ...)
Parameters:
Back to top
coroutine.status
Available since version: Gideros 2011.6
Description:
returns co status: "running", "suspended" or "dead"
Syntax:
coroutine.status(co)
Parameters:
Back to top
coroutine.wrap
Available since version: Gideros 2011.6
Description:
creates coroutine with body f, returns function that resumes co
Syntax:
coroutine.wrap(f)
Parameters:
Back to top
coroutine.yield
Available since version: Gideros 2011.6
Description:
suspend execution of calling coroutine
Syntax:
coroutine.yield(val1, ...)
Parameters:
Back to top
Back to top
debug.debug
Available since version: Gideros 2011.6
Description:
enters interactive debug mode, line with only "cont" terminates
Syntax:
debug.debug()
Back to top
debug.gethook
Available since version: Gideros 2011.6
Description:
returns current hook function, hook mask, hook count
Syntax:
debug.gethook()
Back to top
debug.getinfo
Available since version: Gideros 2011.6
Description:
returns table with information about a function
Syntax:
debug.getinfo(function [, what])
Parameters:
Back to top
debug.getlocal
Available since version: Gideros 2011.6
Description:
returns name and value of local variable with index local at stack level
Syntax:
debug.getlocal(level, local)
Parameters:
Back to top
debug.getupvalue
Available since version: Gideros 2011.6
Description:
returns name and value of upvalue with index up of function func
Syntax:
debug.getupvalue(func, up)
Parameters:
Back to top
debug.sethook
Available since version: Gideros 2011.6
Description:
sets given function as a hook, mask="[crl]"
Syntax:
debug.sethook(hook, mask [, count])
Parameters:
Back to top
debug.setlocal
Available since version: Gideros 2011.6
Description:
sets local variable with index local at stack level with value
Syntax:
debug.setlocal(level, local, value)
Parameters:
Back to top
debug.setupvalue
Available since version: Gideros 2011.6
Description:
sets upvalue with index up of function func with value
Syntax:
debug.setupvalue(func, up, value)
Parameters:
Back to top
debug.traceback
Available since version: Gideros 2011.6
Description:
returns a string with a traceback of the call stack
Syntax:
debug.traceback(message)
Parameters:
Back to top
Event
Supported platforms:
Available since version: Gideros 2011.6
Description:
The objects of
Event class contains information about an event that has occurred.
Event objects
are passed to event listeners when an event occurs.
Usually event objects contains specific additional information about the event that has occured. For example,
when an
Event.MOUSE_DOWN
event occurs,
x
and
y
fields contain the coordinates.
Users can create their own events and dispatch through the event mechanism.
Common uses and examples:
Mouse down event example
function onMouseDown(event)
print(event.x, event.y)
end
mysprite:addEventListener(Event.MOUSE_DOWN, onMouseDown)
User created event
local event = Event.new("myevent")
event.data1 = "12345"
event.data2 = "abcde"
mydispatcher:dispatchEvent(event)
Back to top
Event.new
Available since version: Gideros 2011.6
Description:
Syntax:
Event.new(type)
Parameters:
Back to top
Event:getTarget
Available since version: Gideros 2011.6
Description:
Returns the element on which the event listener was registered.
Syntax:
Event:getTarget()
Back to top
Event:getType
Available since version: Gideros 2011.6
Description:
Returns a string that represents the type of the event.
Syntax:
Event:getType()
Back to top
Event:stopPropagation
Available since version: Gideros 2011.6
Description:
Disables the propagation of the current event in the scene tree hierarchy.
Syntax:
Event:stopPropagation()
Back to top
EventDispatcher
Supported platforms:
Available since version: Gideros 2011.6
Description:
All classes that dispatch events inherit from
EventDispatcher. The target of an event is a listener function and an optional data value.
When an event is dispatched, the registered function is called.
If the optional data value is given, it is used as a first parameter while calling the listener function.
Event dispatching and event targets are the core part of the Gideros event model. Different event types (such as
Event.ENTER_FRAME
,
Event.TOUCHES_BEGIN
or
Event.MOUSE_DOWN
) flow through the scene tree hierarchy differently. When a touch or mouse event occurs, Gideros dispatches an event object into the event flow from the root of the scene tree.
On the other hand,
Event.ENTER_FRAME
event is dispatched to all
Sprite objects.
If you want to define a class that dispatches events, you can inherit your class from
EventDispatcher.
Common uses and examples:
-- example 1
ClassA = Core.class(EventDispatcher)
ClassB = Core.class(EventDispatcher)
function ClassA:funcA(event)
print("funcA", self, event:getType(), event:getTarget())
end
local a = ClassA.new()
local b = ClassB.new()
b:addEventListener("myevent", a.funcA, a) -- when b dispatches an "myevent" event,
-- a.funcA will be called with 'a'
-- as first parameter
b:dispatchEvent(Event.new("myevent")) -- will print "funcA"
-- example 2
Ball = Core.class(Sprite)
function Ball:onEnterFrame()
self:setX(self:getX() 1)
end
ball = Ball.new()
ball:addEventListener(Event.ENTER_FRAME, ball.onEnterFrame, ball)
Back to top
EventDispatcher.new
Available since version: Gideros 2011.6
Description:
Creates a new EventDispatcher object
Syntax:
EventDispatcher.new()
Back to top
EventDispatcher:addEventListener
Available since version: Gideros 2011.6
Description:
Registers a listener function and an optional data value so that the listener function is called when an event
of a particular type occurs.
Syntax:
EventDispatcher:addEventListener(type, listener [, data])
Parameters:
- type: (string) The type of event.
- listener: (function) The listener function that processes the event.
- data: An optional data parameter that is passed as a first argument to the listener function.
Back to top
EventDispatcher:dispatchEvent
Available since version: Gideros 2011.6
Description:
Syntax:
EventDispatcher:dispatchEvent(event)
Parameters:
- event: (Event) The `Event` object to be dispatched.
Back to top
EventDispatcher:hasEventListener
Available since version: Gideros 2011.6
Description:
Checks if the
EventDispatcher object has a event listener registered for the specified type of event.
Syntax:
EventDispatcher:hasEventListener(type)
Parameters:
- type: (string) The type of event.
Back to top
EventDispatcher:removeEventListener
Available since version: Gideros 2011.6
Description:
Removes a listener from the
EventDispatcher object.
removeEventListener()
function expects
the same arguments with
addEventListener()
to remove the event. If there is no matching listener
registered, a call to this function has no effect.
Syntax:
EventDispatcher:removeEventListener(type, listener, data)
Parameters:
- type: (string) The type of event.
- listener: (function) The listener object to remove.
- data: The data parameter that is used while registering the event.
Back to top
Event.APPLICATION_BACKGROUND
Available since version: Gideros 2012.09
Description:
This event is dispatched when application gets sent to background. Sent to background also means application is suspended, thus Event.APPLICATION_SUSPEND
is dispatched first.
Value:
Event.APPLICATION_BACKGROUND = "applicationBackground"
Back to top
Event.APPLICATION_EXIT
Available since version: Gideros 2011.6
Description:
This event is dispatched when application is closed
Value:
Event.APPLICATION_EXIT = "applicationExit"
Back to top
Event.APPLICATION_FOREGROUND
Available since version: Gideros 2012.09
Description:
This event is dispatched when application gets sent back to foreground.
Value:
Event.APPLICATION_FOREGROUND = "applicationForeground"
Back to top
Event.APPLICATION_RESUME
Available since version: Gideros 2011.6
Description:
This event is dispatched when application is resumed (become active)
Value:
Event.APPLICATION_RESUME = "applicationResume"
Back to top
Event.APPLICATION_START
Available since version: Gideros 2011.6
Description:
This event is dispatched when application is started
Value:
Event.APPLICATION_START = "applicationStart"
Back to top
Event.APPLICATION_SUSPEND
Available since version: Gideros 2011.6
Description:
This event is dispatched when application is suspended (becomes inactive).
It does not always mean that application was sent to background, for example, this event is dispatched, when low battery notification is displayed.
Value:
Event.APPLICATION_SUSPEND = "applicationSuspend"
Back to top
Event.MEMORY_WARNING
Available since version: Gideros 2013.09
Description:
This event is dispatched when device has low memory and you can try to free memory in your app, by releasing unnecessary resources.
Value:
Event.MEMORY_WARNING = "memoryWarning"
Back to top
Facebook
Supported platforms:
Available since version: Gideros 2012.09
Description:
Facebook SDK plugin is available for only iOS as an external plugin. To use facebook module:
1. Download and install Facebook SDK from https://developers.facebook.com/ios/downloads/
2. Add FacebookSDK.framework to your project.
3. Add the backward compatibility headers as described https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/#step2
4. Add {Gideros Installation Directory}/All Plugins/Facebook/source/iOS/* files to your Xcode project.
5. If enabled, disable "Application does not run in background" property in .plist file.
The
Facebook class is defined in module "facebook". Therefore, you need to call
require("facebook")
before using it. Loading the Facebook module
also creates a global variable
facebook of type
Facebook for direct use.
Back to top
Facebook:authorize
Available since version: Gideros 2012.09
Description:
Starts the authorization flow for the user with the requested permissions.
Syntax:
Facebook:authorize(permissions)
Parameters:
- permissions: (table, optional) An array of the requested permissions.
Back to top
Facebook:dialog
Available since version: Gideros 2012.09
Description:
Generate a UI dialog for the desired action.
Syntax:
Facebook:dialog(action, paramaters)
Parameters:
- action: (string) The type of dialog to call. Currently supported methods are oauth, feed, and apprequests.
- paramaters: (table, optional) Table representing parameters specific to a particular dialog.
Back to top
Facebook:extendAccessToken
Available since version: Gideros 2012.09
Description:
Extends the access token.
Syntax:
Facebook:extendAccessToken()
Back to top
Facebook:extendAccessTokenIfNeeded
Available since version: Gideros 2012.09
Description:
Attempts to extend the access token. The access token expires after a certain amount of time and when you call this method it will be refreshed if it is still active and only after some time has passed since the last refresh. To ensure that you keep the access token fresh for active users, call this method in your Application.RESUME
event.
Syntax:
Facebook:extendAccessTokenIfNeeded()
Back to top
Facebook:getAccessToken
Available since version: Gideros 2012.09
Description:
Returns the access token.
Syntax:
Facebook:getAccessToken()
Back to top
Facebook:getExpirationDate
Available since version: Gideros 2012.09
Description:
Returns the expiration date;
Syntax:
Facebook:getExpirationDate()
Back to top
Facebook:graphRequest
Available since version: Gideros 2012.09
Description:
Makes a request to the Graph API.
Syntax:
Facebook:graphRequest(graphPath, paramaters, method)
Parameters:
- graphPath: (string) The path to the Graph API endpoint. For example, to fetch data about the currently logged in user this parameter should be ''me'', representing a call to the https://graph.facebook.com/me endpoint.
- paramaters: (table, optional) Table representing the API call parameters.
- method: (string, optional) HTTP method.
Back to top
Facebook:isSessionValid
Available since version: Gideros 2012.09
Description:
Checks if the access token is available and has not expired.
Syntax:
Facebook:isSessionValid()
Back to top
Facebook:logout
Available since version: Gideros 2012.09
Description:
Invalidates the current user session. This method does not unauthorized the application, it simply invalidates the access token. The user can unauthorized the application through the app settings page on the Facebook website.
Syntax:
Facebook:logout()
Back to top
Facebook:setAccessToken
Available since version: Gideros 2012.09
Description:
Sets the access token.
Syntax:
Facebook:setAccessToken(accessToken)
Parameters:
Back to top
Facebook:setAppId
Available since version: Gideros 2012.09
Description:
Initializes the Facebook library and sets App ID. This function should be called first before other functions.
Syntax:
Facebook:setAppId(appId)
Parameters:
- appId: (string) The Facebook application id.
Back to top
Facebook:setExpirationDate
Available since version: Gideros 2012.09
Description:
Sets the expiration date.
Syntax:
Facebook:setExpirationDate(expirationDate)
Parameters:
Back to top
Facebook:shouldExtendAccessToken
Available since version: Gideros 2012.09
Description:
Returns if the access token should be extended.
Syntax:
Facebook:shouldExtendAccessToken()
Back to top
Event.DIALOG_CANCEL
Available since version: Gideros 2012.09
Description:
Dispatched when a Facebook dialog is cancelled.
Value:
Event.DIALOG_CANCEL = "dialogCancel"
Back to top
Event.DIALOG_COMPLETE
Available since version: Gideros 2012.09
Description:
Dispatched when a Facebook dialog has finished.
Value:
Event.DIALOG_COMPLETE = "dialogComplete"
Back to top
Event.DIALOG_ERROR
Available since version: Gideros 2012.09
Description:
Dispatched when a Facebook dialog has failed.
Value:
Event.DIALOG_ERROR = "dialogError"
Event properties:
- errorCode: (number) code of occurred error
- errorDescription: (string) Description of the error
Back to top
Event.LOGIN_CANCEL
Available since version: Gideros 2012.09
Description:
Dispatched when the user cancelled Facebook login.
Value:
Event.LOGIN_CANCEL = "loginCancel"
Back to top
Event.LOGIN_COMPLETE
Available since version: Gideros 2012.09
Description:
Dispatched when the user has logged in with Facebook
Value:
Event.LOGIN_COMPLETE = "loginComplete"
Back to top
Event.LOGIN_ERROR
Available since version: Gideros 2012.09
Description:
Dispatched when a Facebook dialog has failed. event.errorCode
and event.errorDescription
fields give detailed information about the fail reason.
Value:
Event.LOGIN_ERROR = "loginError"
Back to top
Event.LOGOUT_COMPLETE
Available since version: Gideros 2012.09
Description:
Dispatched when the user has logged out with Facebook.
Value:
Event.LOGOUT_COMPLETE = "logoutComplete"
Back to top
Event.REQUEST_COMPLETE
Available since version: Gideros 2012.09
Description:
Dispatched when a Facebook graph request returns a response.
Value:
Event.REQUEST_COMPLETE = "requestComplete"
Event properties:
- response: (string) contains the raw response of the completed Facebook graph request.
Back to top
Event.REQUEST_ERROR
Available since version: Gideros 2012.09
Description:
Dispatched when a Facebook graph request has failed.
Value:
Event.REQUEST_ERROR = "requestError"
Event properties:
- errorCode: (number) code of occurred error
- errorDescription: (string) Description of the error
Back to top
Back to top
file.close
Available since version: Gideros 2011.6
Description:
closes file
Syntax:
file.close()
Back to top
file.flush
Available since version: Gideros 2011.6
Description:
saves any written data to file
Syntax:
file.flush()
Back to top
file.lines
Available since version: Gideros 2011.6
Description:
returns iterator function to return lines, nil ends
Syntax:
file.lines()
Back to top
file.read
Available since version: Gideros 2011.6
Description:
reads file according to given formats, returns read values or nil
Syntax:
file.read(format1, ...)
Parameters:
Back to top
file.seek
Available since version: Gideros 2011.6
Description:
sets file pos, whence="set"|"cur"|"end", defaults "curr",0, returns file pos
Syntax:
file.seek(whence [, offset])
Parameters:
Back to top
file.write
Available since version: Gideros 2011.6
Description:
writes strings or numbers to file
Syntax:
file.write(value1, ...)
Parameters:
Back to top
flurry
Supported platforms:
Available since version: Gideros 2011.6
Description:
This table stores all the functions related to Flurry analytics library.
Flurry is available only for iOS as an external plugin. To use flurry:
1. Create an account on
http://www.flurry.com and follow the instructions about creating a new application.
2. Download Flurry header and libraries and add them to your Xcode project.
3. Add {Gideros Installation Directory}/All Plugins/Flurry/source/iOS/flurry.mm file to your Xcode project.
To load the Flurry library, call
require "flurry"
.
Back to top
flurry.endTimedEvent
Available since version: Gideros 2011.6
Description:
Use this function to end timed event before app exists, otherwise timed events automatically end when app exists. When ending the timed event,
a new event parameters table can be used to update event parameters. If you don't specify a new event parameters table, event parameters are kept the same.
Syntax:
flurry.endTimedEvent(eventName, parameters)
Parameters:
- eventName: (string) The event name of end timed event.
- parameters: (table, optional) If specified, event paramaters updated for this event.
Back to top
flurry.isAvailable
Available since version: Gideros 2011.6
Description:
Returns true
if Flurry is available for this platform. Currently, Flurry is available only for iOS.
Syntax:
flurry.isAvailable()
Back to top
flurry.logEvent
Available since version: Gideros 2011.6
Description:
Use this function to count the number of times certain events happen during a session of your application and to pass dynamic parameters
to be recorded with that event. Event parameters is optional and can be passed in as a table value. Your application is currently limited to counting
occurrences for 100 different event ids (maximum length 255 characters). Maximum of 10 event parameters per event is supported.
To start a timed event, pass timed
parameter as true
.
Syntax:
flurry.logEvent(eventName, parameters, timed)
Parameters:
- eventName: (string) The event name to be logged at Flurry service.
- parameters: (table, optional) Optional paramaters to be recorted with this event.
- timed: (boolean, optional) Specifies this is a timed event.
Examples:
flurry.logEvent("myEvent1")
flurry.logEvent("myEvent2", {key="value"})
flurry.logEvent("myEvent3", {key="value"}, true)
Back to top
flurry.startSession
Available since version: Gideros 2011.6
Description:
Starts the Flurry session with your API key. To create an account on Flurry and to obtain the API key specific to your application,
please visit
http://www.flurry.com and follow the instructions there.
You need to call this function once after your application starts. For example,
init.lua
is suitable to call this function.
Syntax:
flurry.startSession(apiKey)
Parameters:
- apiKey: (string) The Flurry API key.
Back to top
Font
Supported platforms:
Available since version: Gideros 2011.6
Description:
The 'Font' class is used to load fonts created by "Gideros Font Creator".

(images/font_creator.png "Gideros Font Creator")
Gideros Font Creator exports two files: A **.txt** file that specifes the positions of character glyph a **.png** file of font.
Use these two files to create
Font object as:
local font = Font.new("font.txt", "font.png")
Back to top
Font.new
Available since version: Gideros 2011.6
Description:
Creates a new
Font object.
Syntax:
Font.new(txtfile, imagefile, filtering)
Parameters:
- txtfile: (string)
- imagefile: (string)
- filtering: (boolean, default = false) Whether or not the font texture is filtered
Back to top
Back to top
FontBase:getAdvanceX
Available since version: Gideros 2011.6
Description:
Returns the width of the first size
characters of text
.
Note that this value is not equal to the 3rd return value (width) of getBounds()
.
getBounds()
returns a rectangle describing the bounds this string will cover
whereas getAdvanceX()
returns the distance to where the next string should be drawn.
Syntax:
FontBase:getAdvanceX(text, letterSpacing, size)
Parameters:
- text: (string)
- letterSpacing: (number, default = 0)
- size: (number, optional)
Back to top
FontBase:getAscender
Available since version: Gideros 2011.6
Description:
Returns the ascender of the font. The ascender of a font is the distance from the baseline to the highest position characters extend to.
Syntax:
FontBase:getAscender()
Back to top
FontBase:getBounds
Available since version: Gideros 2011.6
Description:
Returns the tight bounding rectangle of the characters in the string specified by text
.
Syntax:
FontBase:getBounds(text)
Parameters:
Back to top
FontBase:getLineHeight
Available since version: Gideros 2011.6
Description:
Returns the distance from one base line to the next.
Syntax:
FontBase:getLineHeight()
Back to top
Geolocation
Supported platforms:
Available since version: Gideros 2012.8
Description:
The
Geolocation class is used to configure the parameters and dispatching of location and heading related events.
Common uses and examples:
geolocation = Geolocation.new()
local function onLocationUpdate(event)
print("location: ", event.latitude, event.longitude, event.altitude)
end
local function onHeadingUpdate(event)
print("heading: ", event.magneticHeading, event.trueHeading)
end
geolocation:addEventListener(Event.LOCATION_UPDATE, onLocationUpdate)
geolocation:addEventListener(Event.HEADING_UPDATE, onHeadingUpdate)
geolocation:start()
Back to top
Geolocation.getAccuracy
Available since version: Gideros 2012.8
Description:
Returns the previously set desired accuracy.
Syntax:
Geolocation.getAccuracy()
Back to top
Geolocation.getThreshold
Available since version: Gideros 2012.8
Description:
Returns the previously set minimum distance threshold.
Syntax:
Geolocation.getThreshold()
Back to top
Geolocation.isAvailable
Available since version: Gideros 2012.8
Description:
Returns true
if the device has the capability to determine current location and this capability is enabled, false
otherwise.
Syntax:
Geolocation.isAvailable()
Back to top
Geolocation.isHeadingAvailable
Available since version: Gideros 2012.8
Description:
Returns true
if the device has the capability to determine heading, false
otherwise.
Syntax:
Geolocation.isHeadingAvailable()
Back to top
Geolocation.new
Available since version: Gideros 2012.8
Description:
Creates new Geolocation instance
Syntax:
Geolocation.new()
Back to top
Geolocation.setAccuracy
Available since version: Gideros 2012.8
Description:
Sets the desired accuracy (in meters) of the location data. The receiver does its best to achieve the requested
accuracy. However the actual accuracy is not guaranteed. The default value is 0 (best accuracy).
Syntax:
Geolocation.setAccuracy(accuracy)
Parameters:
- accuracy: (number) the desired accuracy
Back to top
Geolocation.setThreshold
Available since version: Gideros 2012.8
Description:
Sets the minimum distance (in meters) threshold. If threshold distance is greater than 0,
a location event will only be dispatched if the device moves by threshold. The default value
is 0 (as frequently as possible).
Syntax:
Geolocation.setThreshold(threshold)
Parameters:
- threshold: (number) the minimum distance threshold
Back to top
Geolocation:start
Available since version: Gideros 2012.8
Description:
Starts the generation of updates that report the current location and heading.
Syntax:
Geolocation:start()
Back to top
Geolocation:startUpdatingHeading
Available since version: Gideros 2012.8
Description:
Starts the generation of updates that report the heading.
Syntax:
Geolocation:startUpdatingHeading()
Back to top
Geolocation:startUpdatingLocation
Available since version: Gideros 2012.8
Description:
Starts the generation of updates that report the current location.
Syntax:
Geolocation:startUpdatingLocation()
Back to top
Geolocation:stop
Available since version: Gideros 2012.8
Description:
Stops the generation of updates that report the current location and heading.
Syntax:
Geolocation:stop()
Back to top
Geolocation:stopUpdatingHeading
Available since version: Gideros 2012.8
Description:
Stops the generation of updates that report the heading.
Syntax:
Geolocation:stopUpdatingHeading()
Back to top
Geolocation:stopUpdatingLocation
Available since version: Gideros 2012.8
Description:
Stops the generation of updates that report the current location.
Syntax:
Geolocation:stopUpdatingLocation()
Back to top
Event.ERROR
Available since version: Gideros 2011.6
Description:
This event is dispatched, when there is an error and
Geolocation can not be used currently
Value:
Event.ERROR = "error"
Back to top
Event.HEADING_UPDATE
Available since version: Gideros 2011.6
Description:
This event is dispatched on each user heading direction update
Value:
Event.HEADING_UPDATE = "headingUpdate"
Event properties:
- magneticHeading: (number) The value in this property represents the heading relative to the magnetic North Pole, which is different from the geographic North Pole. The value 0 means the device is pointed toward magnetic north, 90 means it is pointed east, 180 means it is pointed south, and so on.
- trueHeading: (number) The value in this property represents the heading relative to the geographic North Pole. The value 0 means the device is pointed toward true north, 90 means it is pointed due east, 180 means it is pointed due south, and so on. A negative value indicates that the heading could not be determined.
Back to top
Event.LOCATION_UPDATE
Available since version: Gideros 2011.6
Description:
This event is dispatched on each user location update
Value:
Event.LOCATION_UPDATE = "locationUpdate"
Event properties:
- latitude: (number) The latitude of current user position
- longitude: (number) The longitude of current user position
- altitude: (number) The possible altitude of user
Back to top
GoogleBilling
Supported platforms:
Available since version: Gideros 2012.09
Description:
The
GoogleBilling class is defined in the module "googlebilling". Therefore, you need to call
require("googlebilling")
before using it. Loading the Google Billing module
also creates a global variable
googlebilling of type
GoogleBilling for direct use.
GoogleBilling Events and Response Codes
GoogleBilling class dispatches 5 events:
Event.CHECK_BILLING_SUPPORTED_COMPLETE
,
Event.REQUEST_PURCHASE_COMPLETE
,
Event.RESTORE_TRANSACTIONS_COMPLETE
,
Event.CONFIRM_NOTIFICATION_COMPLETE
and
Event.PURCHASE_STATE_CHANGE
.
Event.*_COMPLETE
events contains a field
event.responseCode
which provides status information
and error information about a request. Response code can be one of these values:
GoogleBilling.OK
: Indicates that the request was sent to the server successfully. When this code is returned
in response to a
checkBillingSupported
function, indicates that billing is supported.
GoogleBilling.USER_CANCELED
: Indicates that the user pressed the back button on the checkout page instead of buying the item.
GoogleBilling.SERVICE_UNAVAILABLE
: Indicates that the network connection is down.
GoogleBilling.BILLING_UNAVAILABLE
: Indicates that in-app billing is not available because the API version that
you specified is not recognized by the Google Play application or the user is ineligible for in-app billing
(for example, the user resides in a country that prohibits in-app purchases).
GoogleBilling.ITEM_UNAVAILABLE
: Indicates that Google Play cannot find the requested item in the application's product list.
This can happen if the product ID is misspelled in your
requestPurchase
function or if an item is unpublished in the application's product list.
GoogleBilling.DEVELOPER_ERROR
: Indicates that an application is trying to make an in-app billing request but the application has not declared the
com.android.vending.BILLING permission in its manifest. Can also indicate that an application is not properly signed,
or that you sent a malformed request, such as a request with missing Bundle keys or a request that uses an unrecognized request type.
GoogleBilling.ERROR
: Indicates an unexpected server error. For example, this error is triggered if you try to purchase an item from yourself, which is not allowed by Google Wallet.
# Event.CHECK_BILLING_SUPPORTED_COMPLETE
Dispatched when
checkBillingSuported
function completes. It contains
event.responseCode
and
event.productType
fields.
# Event.REQUEST_PURCHASE_COMPLETE
Dispatched when
requestPurchase
function completes. It contains
event.responseCode
,
event.productId
,
event.productType
and
event.developerPayload
fields.
# Event.RESTORE_TRANSACTIONS_COMPLETE
Dispatched when
restoreTransactions
function completes. It contains
event.responseCode
fields.
# Event.CONFIRM_NOTIFICATION_COMPLETE
Dispatched when
confirmNotification
function completes. It contains
event.responseCode
and
event.notificationId
fields.
# Event.PURCHASE_STATE_CHANGE
Dispatched when information about a transaction is received. It contains
event.purchaseState
,
event.productId
,
event.notificationId
,
event.purchaseTime
and
event.developerPayload
fields.
Back to top
GoogleBilling:checkBillingSupported
Available since version: Gideros 2012.09
Description:
This request verifies that the Google Play application supports in-app billing.
You usually send this request when your application first starts up. This request is
useful if you want to enable or disable certain UI features that are relevant only to
in-app billing.
Syntax:
GoogleBilling:checkBillingSupported(productType)
Parameters:
- productType: (string, optional) The item type. It can be GoogleBilling.INAPP or GoogleBilling.SUBS.
Back to top
GoogleBilling:confirmNotification
Available since version: Gideros 2012.09
Description:
This request acknowledges that your application received the details of a purchase state change.
Syntax:
GoogleBilling:confirmNotification(notificationId)
Parameters:
Back to top
GoogleBilling:requestPurchase
Available since version: Gideros 2012.09
Description:
This request sends a purchase message to the Google Play application and is the foundation of in-app billing.
You send this request when a user indicates that he or she wants to purchase an item in your application.
Google Play then handles the financial transaction by displaying the checkout user interface.
Syntax:
GoogleBilling:requestPurchase(productId, productType, developerPayload)
Parameters:
- productId: (string)
- productType: (string, optional)
- developerPayload: (string, optional)
Back to top
GoogleBilling:restoreTransactions
Available since version: Gideros 2012.09
Description:
This request retrieves a user's transaction status for managed purchases. You should send this message only when you need to
retrieve a user's transaction status, which is usually only when your application is reinstalled or installed for the first time on a device.
Syntax:
GoogleBilling:restoreTransactions()
Back to top
GoogleBilling:setApiVersion
Available since version: Gideros 2012.09
Description:
Sets the API version. You can find more information http://developer.android.com/guide/google/play/billing/billing_reference.html#billing-versions
Syntax:
GoogleBilling:setApiVersion(apiVersion)
Parameters:
Back to top
GoogleBilling:setPublicKey
Available since version: Gideros 2012.09
Description:
Sets the public key. You can find the public key portion of this key pair on your Google Play account's profile page.
Syntax:
GoogleBilling:setPublicKey(publicKey)
Parameters:
- publicKey: (string) Your Google Play public key
Back to top
Event.CHECK_BILLING_SUPPORTED_COMPLETE
Available since version: Gideros 2012.09
Description:
Dispatched when GoogleBilling:checkBillingSupported
function completes with these response codes:
GoogleBilling.OK
indicates that purchases can be made
GoogleBilling.SERVICE_UNAVAILABLE
indicates that the network connection is down and
GoogleBilling.BILLING_UNAVAILABLE
indicates that in-app billing is not available because the API version that you specified is not recognized by the Google Play application or the user is ineligible for in-app billing (for example, the user resides in a country that prohibits in-app purchases).
Value:
Event.CHECK_BILLING_SUPPORTED_COMPLETE = "checkBillingSupportedComplete"
Event properties:
- responseCode: (string) response code
- productType: (string) type of product available or nil if any product type can be used
Back to top
Event.CONFIRM_NOTIFICATION_COMPLETE
Available since version: Gideros 2012.09
Description:
Dispatched when GoogleBilling:confirmNotification
function completes with these response codes:
GoogleBilling.OK
indicates that the request was sent to the server successfully.
GoogleBilling.ERROR
indicates an unexpected server error. For example, this error is triggered if you try to purchase an item from yourself, which is not allowed by Google Wallet.
GoogleBilling.DEVELOPER_ERROR
indicates that an application is trying to make an in-app billing request but the application has not declared the com.android.vending.BILLING permission in its manifest. Can also indicate that an application is not properly signed, or that you sent a malformed request, such as a request with missing Bundle keys or a request that uses an unrecognized request type.
Value:
Event.CONFIRM_NOTIFICATION_COMPLETE = "confirmNotificationComplete"
Event properties:
- responseCode: (string) response code
- notificationId: (string) id of notification that was confirmed
Back to top
Event.PURCHASE_STATE_CHANGE
Available since version: Gideros 2012.09
Description:
Dispatched when information about a transaction is received with these purchase states:
GoogleBilling.CANCELED
indicates that purchase was canceled
GoogleBilling.PURCHASED
indicates that item was purchased you can enable it in your app
GoogleBilling.REFUNDED
indicates that item previously purchased was refunded, remove purchased item from users app
GoogleBilling.EXPIRED
indicates that item previously subscribed is expired, disable any subscription services
Value:
Event.PURCHASE_STATE_CHANGE = "purchaseStateChange"
Event properties:
- purchaseState: (string) purchase state
- productId: (string) your assigned product id
- notificationId: (string) id of notification, that you need to confirm
- purchaseTime: (string) time when purchase was made
- developerPayload: (string) A developer-specified string that can be specified when you make a purchase request.
Back to top
Event.REQUEST_PURCHASE_COMPLETE
Available since version: Gideros 2012.09
Description:
Dispatched when GoogleBilling:requestPurchase
function completes with these response codes:
GoogleBilling.USER_CANCELED
indicates that the user pressed the back button on the checkout page instead of buying the item.
GoogleBilling.SERVICE_UNAVAILABLE
indicates that the network connection is down.
GoogleBilling.BILLING_UNAVAILABLE
indicates that in-app billing is not available because the API version that you specified is not recognized by the Google Play application or the user is ineligible for in-app billing (for example, the user resides in a country that prohibits in-app purchases).
GoogleBilling.ITEM_UNAVAILABLE
indicates that Google Play cannot find the requested item in the application's product list.
GoogleBilling.DEVELOPER_ERROR
Indicates that an application is trying to make an in-app billing request but the application has not declared the com.android.vending.BILLING permission in its manifest. Can also indicate that an application is not properly signed, or that you sent a malformed request, such as a request with missing Bundle keys or a request that uses an unrecognized request type.
GoogleBilling.ERROR
indicates an unexpected server error. For example, this error is triggered if you try to purchase an item from yourself, which is not allowed by Google Wallet.
Value:
Event.REQUEST_PURCHASE_COMPLETE = "requestPurchaseComplete"
Event properties:
- productId: (string) your given id of the product purchased
- responseCode: (string) response code.
- productType: (string) type of the product purchased
- developerPayload: (string) A developer-specified string that can be specified when you make a purchase request.
Back to top
Event.RESTORE_TRANSACTIONS_COMPLETE
Available since version: Gideros 2012.09
Description:
Dispatched when GoogleBilling:restoreTransactions
function completes with these response codes:
GoogleBilling.OK
indicates that the request was sent to the server successfully.
GoogleBilling.ERROR
indicates an unexpected server error. For example, this error is triggered if you try to purchase an item from yourself, which is not allowed by Google Wallet.
GoogleBilling.DEVELOPER_ERROR
indicates that an application is trying to make an in-app billing request but the application has not declared the com.android.vending.BILLING permission in its manifest. Can also indicate that an application is not properly signed, or that you sent a malformed request, such as a request with missing Bundle keys or a request that uses an unrecognized request type.
Value:
Event.RESTORE_TRANSACTIONS_COMPLETE = "restoreTransactionsComplete"
Event properties:
- responseCode: (string) response code
Back to top
GoogleBilling.BILLING_UNAVAILABLE
Available since version: Gideros 2012.09
Description:
Indicates that in-app billing is not available because the API version that you specified is not recognized by the Google Play application or the user is ineligible for in-app billing (for example, the user resides in a country that prohibits in-app purchases).
Value:
GoogleBilling.BILLING_UNAVAILABLE = "billingUnavailable"
Back to top
GoogleBilling.CANCELED
Available since version: Gideros 2012.09
Description:
Indicates status of order as canceled, when user interrupted the purchase in the middle. Don't unlock content on this state.
Value:
GoogleBilling.CANCELED = "canceled"
Back to top
GoogleBilling.DEVELOPER_ERROR
Available since version: Gideros 2012.09
Description:
Indicates that an application is trying to make an in-app billing request but the application has not declared the com.android.vending.BILLING permission in its manifest. Can also indicate that an application is not properly signed, or that you sent a malformed request, such as a request with missing Bundle keys or a request that uses an unrecognized request type.
Value:
GoogleBilling.DEVELOPER_ERROR = "developerError"
Back to top
GoogleBilling.ERROR
Available since version: Gideros 2012.09
Description:
Indicates an unexpected server error. For example, this error is triggered if you try to purchase an item from yourself, which is not allowed by Google Wallet.
Value:
GoogleBilling.ERROR = "error"
Back to top
GoogleBilling.EXPIRED
Available since version: Gideros 2012.09
Description:
Indicates status of order as expired. It mean that there was a subscription for this user, which now is expired and you need to lock the subscription service back, and probably notify user about renewing this subscription on this state.
Value:
GoogleBilling.EXPIRED = "expired"
Back to top
GoogleBilling.INAPP
Available since version: Gideros 2012.09
Description:
Indicates the product type as in app purchase
Value:
GoogleBilling.INAPP = "inapp"
Back to top
GoogleBilling.ITEM_UNAVAILABLE
Available since version: Gideros 2012.09
Description:
Indicates that Google Play cannot find the requested item in the application's product list.
This can happen if the product ID is misspelled in your GoogleBilling:requestPurchase
function or if an item is unpublished in the application's product list.
Value:
GoogleBilling.ITEM_UNAVAILABLE = "itemUnavailable"
Back to top
GoogleBilling.OK
Available since version: Gideros 2012.09
Description:
Indicates that the request was sent to the server successfully. When this code is returned in response to a GoogleBilling:checkBillingSupported
function, indicates that billing is supported.
Value:
GoogleBilling.OK = "ok"
Back to top
GoogleBilling.PURCHASED
Available since version: Gideros 2012.09
Description:
Indicates status of order as purchased. You can unlock the content on this state
Value:
GoogleBilling.PURCHASED = "purchased"
Back to top
GoogleBilling.REFUNDED
Available since version: Gideros 2012.09
Description:
Indicates status of order as refunded. Meaning user asked money back, you need to lock the content that you provided previously on this state.
Value:
GoogleBilling.REFUNDED = "refunded"
Back to top
GoogleBilling.SERVICE_UNAVAILABLE
Available since version: Gideros 2012.09
Description:
Indicates that the network connection is down.
Value:
GoogleBilling.SERVICE_UNAVAILABLE = "serviceUnavailable"
Back to top
GoogleBilling.SUBS
Available since version: Gideros 2012.09
Description:
Indicates the product type as subscription
Value:
GoogleBilling.SUBS = "subs"
Back to top
GoogleBilling.USER_CANCELED
Available since version: Gideros 2012.09
Description:
Indicates that the user pressed the back button on the checkout page instead of buying the item.
Value:
GoogleBilling.USER_CANCELED = "userCanceled"
Back to top
Gyroscope
Supported platforms:
Available since version: Gideros 2012.8
Description:
The
Gyroscope class is used to access gyroscope data.
Common uses and examples:
local gyroscope = Gyroscope.new()
gyroscope:start()
local angx = 0
local angy = 0
local angz = 0
local function onEnterFrame(event)
local x, y, z = gyroscope:getRotationRate()
angx = angx x * event.deltaTime
angy = angy y * event.deltaTime
angz = angz z * event.deltaTime
print(angx * 180 / math.pi, angy * 180 / math.pi, angz * 180 / math.pi)
end
stage:addEventListener("enterFrame", onEnterFrame)
Back to top
Gyroscope.isAvailable
Available since version: Gideros 2012.8
Description:
Returns true
if gyroscope is available for this platform, false
otherwise.
Syntax:
Gyroscope.isAvailable()
Back to top
Gyroscope.new
Available since version: Gideros 2012.8
Description:
Creates new Gyroscope instance
Syntax:
Gyroscope.new()
Back to top
Gyroscope:getRotationRate
Available since version: Gideros 2012.8
Description:
Returns the device's rate of rotation around three axes in radians per second.
Syntax:
Gyroscope:getRotationRate()
Back to top
Gyroscope:start
Available since version: Gideros 2012.8
Description:
Starts the generation of gyroscope samples.
Syntax:
Gyroscope:start()
Back to top
Gyroscope:stop
Available since version: Gideros 2012.8
Description:
Stops the generation of gyroscope samples.
Syntax:
Gyroscope:stop()
Back to top
iad
Supported platforms:
Available since version: Gideros 2012.8
Description:
iAd module for iOS allows you to use iAd framework that was introduced in iOS 4.0. To load the iAd module, call
require "iad"
. After loading iAd module,
iad table stores all
classes and functions related to iAd framework.
Back to top
iad.isAvailable
Available since version: Gideros 2012.8
Description:
Returns true
if iAd framework is available for this platform, false
otherwise. For iOS 4.0 , this function returns true
.
Syntax:
iad.isAvailable()
Back to top
iad.Banner
Supported platforms:
Available since version: Gideros 2012.8
Description:
The
iad.Banner class provides a view that displays banner advertisements to the user. When the user taps a banner view, the view triggers an action
programmed into the advertisement. For example, an advertisement might show a movie, present a modal advertisement, or launch Safari to show a webpage.
Your application is notified when an action starts and stops, but does not otherwise interact with the advertisement.
Back to top
iad.Banner.new
Available since version: Gideros 2012.8
Description:
Creates an
iad.Banner instance. If iAd framework is not available, this function gives an error.
The alignment and the orientation of the ad banner are defined by these 4 string constants:
iad.Banner.TOP = "top"
iad.Banner.BOTTOM = "bottom"
iad.Banner.PORTRAIT = "portrait"
iad.Banner.LANDSCAPE = "landscape"
And
iad.Banner class dispatches these 4 events:
Event.BANNER_AD_LOADED = "bannerAdLoaded"
Event.BANNER_AD_FAILED = "bannerAdFailed"
Event.BANNER_ACTION_BEGIN = "bannerActionBegin"
Event.BANNER_ACTION_FINISHED = "bannerActionFinished"
When an ad banner is created, iAd will start requesting ads. Apple serves ads, and refreshes with new ads, on an automatic timer.
Apple also requires that the ad area be hidden when no ad is available to display. iAd module manages all this behavior for you automatically.
When an ad becomes available, it will be displayed on the screen, the event
Event.BANNER_AD_LOADED
is dispatched when one is about to be displayed,
or the event
Event.BANNER_AD_FAILED
is dispatched when the loading has failed. If the loading has failed, the fields
event.errorCode
and
event.errorDescription
contains information about the failure reason.
When the user clicks on an ad, the event
Event.BANNER_ACTION_BEGIN
is dispatched. At this time, the user will either be taken out of your application
to view the app store (in this case
event.willLeaveApplication
field will be true), or they will be presented with a fullscreen advertisement to interact with,
and
event.willLeaveApplication
will be false. In the latter case, you may decide to pause the application until the event
Event.BANNER_ACTION_FINISHED
is dispatched.
Syntax:
iad.Banner.new(alignment, orientation)
Parameters:
- alignment: (string) whether you want ads to show top or bottom of the screen. It can be either iad.Banner.TOP or iad.Banner.BOTTOM.
- orientation: (string) orientation of the banner. It can be either iad.Banner.PORTRAIT or iad.Banner.LANDSCAPE.
Examples:
-- if the platform is iOS, load the iAd module
if application:getDeviceInfo() == "iOS" then
require "iad"
end
-- 4 event listeners for debug print
local function onBannerAdLoaded()
print("banner ad loaded")
end
local function onBannerAdFailed(event)
print("banner ad failed", event.errorCode, event.errorDescription)
end
local function onBannerActionBegin(event)
print("banner action begin", event.willLeaveApplication)
end
local function onBannerActionFinished()
print("banner action finished")
end
-- if iAd module is loaded and iAd framework is available, create an ad banner and then show it
local banner = nil
if iad and iad.isAvailable() then
banner = iad.Banner.new(iad.Banner.TOP, iad.Banner.PORTRAIT)
banner:addEventListener(Event.BANNER_AD_LOADED, onBannerAdLoaded)
banner:addEventListener(Event.BANNER_AD_FAILED, onBannerAdFailed)
banner:addEventListener(Event.BANNER_ACTION_BEGIN, onBannerActionBegin)
banner:addEventListener(Event.BANNER_ACTION_FINISHED, onBannerActionFinished)
banner:show() -- show it because newly created banners are not visible by default
end
-- show the banner (if it exists)
function showBanner()
if banner ~= nil then
banner:show()
end
end
-- hide the banner (if it exists)
function hideBanner()
if banner ~= nil then
banner:hide()
end
end
Back to top
iad.Banner:hide
Available since version: Gideros 2012.8
Description:
Hides the ad banner.
Syntax:
iad.Banner:hide()
Back to top
iad.Banner:isBannerLoaded
Available since version: Gideros 2012.8
Description:
Returns true
if the ad banner has downloaded an advertisement, false
otherwise.
Syntax:
iad.Banner:isBannerLoaded()
Back to top
iad.Banner:setAlignment
Available since version: Gideros 2012.8
Description:
Sets the alignment of the banner as the top or bottom.
Syntax:
iad.Banner:setAlignment(alignment)
Parameters:
- alignment: (string) whether you want ads to show top or bottom of the screen. It can be either iad.Banner.TOP or iad.Banner.BOTTOM.
Back to top
iad.Banner:show
Available since version: Gideros 2012.8
Description:
Shows the ad banner if an ad is currently available or when an ad becomes available.
Syntax:
iad.Banner:show()
Back to top
Event.BANNER_ACTION_BEGIN
Available since version: Gideros 2012.8
Description:
This event is dispatched when the user clicks on an ad. At this time, the user will either be taken out of your application to view the app store (in this case event.willLeaveApplication
field will be true), or they will be presented with a fullscreen advertisement to interact with, and event.willLeaveApplication
will be false.
Value:
Event.BANNER_ACTION_BEGIN = "bannerActionBegin"
Event properties:
- willLeaveApplication: (bool) true if user will leave the app, false if user will not leave the app
Back to top
Event.BANNER_ACTION_FINISHED
Available since version: Gideros 2012.8
Description:
This event is dispatched when the user gets back to app after interaction with the ad.
Value:
Event.BANNER_ACTION_FINISHED = "bannerActionFinished"
Back to top
Event.BANNER_AD_FAILED
Available since version: Gideros 2012.8
Description:
This event is dispatched when the loading of ad has failed.
Value:
Event.BANNER_AD_FAILED = "bannerAdFailed"
Event properties:
- errorCode: (number) code of the error
- errorDescription: (string) description of the error
Back to top
Event.BANNER_AD_LOADED
Available since version: Gideros 2012.8
Description:
This event is dispatched when an ad becomes available, and will be displayed on the screen
Value:
Event.BANNER_AD_LOADED = "bannerAdLoaded"
Back to top
iad.Banner.BOTTOM
Available since version: Gideros 2012.8
Description:
Bottom position of vertical alignment of banner
Value:
iad.Banner.BOTTOM = "bottom"
Back to top
iad.Banner.LANDSCAPE
Available since version: Gideros 2012.8
Description:
Landscape orientation of ad
Value:
iad.Banner.LANDSCAPE = "landscape"
Back to top
iad.Banner.PORTRAIT
Available since version: Gideros 2012.8
Description:
Portrait orientation of ad
Value:
iad.Banner.PORTRAIT = "portrait"
Back to top
iad.Banner.TOP
Available since version: Gideros 2012.8
Description:
Top position of vertical alignment of banner
Value:
iad.Banner.TOP = "top"
Back to top
Back to top
io.close
Available since version: Gideros 2011.6
Description:
closes file, or the default output file
Syntax:
io.close(file)
Parameters:
Back to top
io.flush
Available since version: Gideros 2011.6
Description:
flushes the default output file
Syntax:
io.flush()
Back to top
Back to top
io.lines
Available since version: Gideros 2011.6
Description:
open file in read mode, returns iterator function to return lines, nil ends
Syntax:
io.lines(filename)
Parameters:
Back to top
io.open
Available since version: Gideros 2011.6
Description:
opens file in specified mode "[rawb ]", returns handle or nil
Syntax:
io.open(filename [, mode])
Parameters:
Back to top
io.output
Available since version: Gideros 2011.6
Description:
opens file in text mode, sets as default output file, or returns current default output file
Syntax:
io.output(file)
Parameters:
Back to top
io.read
Available since version: Gideros 2011.6
Description:
reads file according to given formats, returns read values or nil
Syntax:
io.read(format1, ...)
Parameters:
Back to top
io.tmpfile
Available since version: Gideros 2011.6
Description:
returns a handle for a temporary file, opened in update mode
Syntax:
io.tmpfile()
Back to top
io.type
Available since version: Gideros 2011.6
Description:
returns "file" if obj is an open file handle, "close file" if closed, or nil if not a file handle
Syntax:
io.type(obj)
Parameters:
Back to top
io.write
Available since version: Gideros 2011.6
Description:
writes strings or numbers to file
Syntax:
io.write(value1, ...)
Parameters:
Back to top
Back to top
json.decode
Available since version: Gideros 2013.09
Description:
Returns Lua table from provided json encoded string
Syntax:
json.decode(jsondata)
Parameters:
- jsondata: (string) Data in json format which to deserialize to Lua table
Back to top
json.encode
Available since version: Gideros 2013.09
Description:
Returns encoded json string from provided Lua table
Syntax:
json.encode(data)
Parameters:
- data: (table) Lua table which to serialize to json
Back to top
Back to top
KeyCode.A
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.A = 65
Back to top
KeyCode.B
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.B = 66
Back to top
KeyCode.BACK
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.BACK = 301
Back to top
KeyCode.C
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.C = 67
Back to top
KeyCode.CENTER
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.CENTER = 304
Back to top
KeyCode.D
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.D = 68
Back to top
KeyCode.DOWN
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.DOWN = 40
Back to top
KeyCode.E
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.E = 82
Back to top
KeyCode.F
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.F = 70
Back to top
KeyCode.G
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.G = 71
Back to top
KeyCode.H
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.H = 72
Back to top
KeyCode.I
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.I = 73
Back to top
KeyCode.J
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.J = 74
Back to top
KeyCode.K
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.K = 75
Back to top
KeyCode.L
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.L = 76
Back to top
KeyCode.L1
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.L1 = 307
Back to top
KeyCode.LEFT
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.LEFT = 37
Back to top
KeyCode.M
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.M = 77
Back to top
Back to top
KeyCode.N
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.N = 78
Back to top
KeyCode.NUM_0
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_0 = 48
Back to top
KeyCode.NUM_1
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_1 = 49
Back to top
KeyCode.NUM_2
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_2 = 50
Back to top
KeyCode.NUM_3
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_3 = 51
Back to top
KeyCode.NUM_4
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_4 = 52
Back to top
KeyCode.NUM_5
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_5 = 53
Back to top
KeyCode.NUM_6
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_6 = 54
Back to top
KeyCode.NUM_7
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_7 = 55
Back to top
KeyCode.NUM_8
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_8 = 56
Back to top
KeyCode.NUM_9
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.NUM_9 = 57
Back to top
KeyCode.O
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.O = 79
Back to top
KeyCode.P
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.P = 80
Back to top
KeyCode.Q
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.Q = 81
Back to top
KeyCode.R1
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.R1 = 308
Back to top
KeyCode.RIGHT
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.RIGHT = 39
Back to top
KeyCode.S
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.S = 83
Back to top
KeyCode.SEARCH
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.SEARCH = 302
Back to top
KeyCode.SELECT
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.SELECT = 305
Back to top
KeyCode.START
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.START = 306
Back to top
KeyCode.T
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.T = 84
Back to top
KeyCode.U
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.U = 85
Back to top
KeyCode.UP
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.UP = 38
Back to top
KeyCode.V
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.V = 86
Back to top
KeyCode.W
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.W = 87
Back to top
KeyCode.X
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.X = 88
Back to top
KeyCode.Y
Available since version: Gideros 2011.6
Description:
Value:
KeyCode.Y = 89
Back to top
KeyCode.Z
Available since version: Gideros 2013.06
Description:
Value:
KeyCode.Z = 90
Back to top
lfs
Supported platforms:
Available since version: Gideros 2012.8
Description:
LFS or LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution.
LuaFileSystem offers a portable way to access the underlying directory structure and file attributes.
Back to top
lpeg
Supported platforms:
Available since version: Gideros 2012.8
Description:
LPeg is a pattern-matching library for Lua, based on Parsing Expression Grammars (PEGs).
Back to top
Back to top
math.abs
Available since version: Gideros 2011.6
Description:
returns absolute value of v
Syntax:
math.abs(v)
Parameters:
Back to top
math.acos
Available since version: Gideros 2011.6
Description:
returns arc cosine value of v in radians
Syntax:
math.acos(v)
Parameters:
Back to top
math.asin
Available since version: Gideros 2011.6
Description:
returns arc sine value of v in radians
Syntax:
math.asin(v)
Parameters:
Back to top
math.atan
Available since version: Gideros 2011.6
Description:
returns arc tangent value of v in radians
Syntax:
math.atan(v)
Parameters:
Back to top
math.atan2
Available since version: Gideros 2011.6
Description:
returns arc tangent value of v1/v2 in radians
Syntax:
math.atan2(v1, v2)
Parameters:
Back to top
math.ceil
Available since version: Gideros 2011.6
Description:
returns smallest integer >= v
Syntax:
math.ceil(v)
Parameters:
Back to top
math.cos
Available since version: Gideros 2011.6
Description:
returns cosine value of angle rad
Syntax:
math.cos(rad)
Parameters:
Back to top
math.deg
Available since version: Gideros 2011.6
Description:
returns angle in degrees of radians rad
Syntax:
math.deg(rad)
Parameters:
Back to top
math.exp
Available since version: Gideros 2011.6
Description:
returns e^v
Syntax:
math.exp(v)
Parameters:
Back to top
math.floor
Available since version: Gideros 2011.6
Description:
returns largest integer <= v
Syntax:
math.floor(v)
Parameters:
Back to top
math.fmod
Available since version: Gideros 2011.6
Description:
returns remainder of v1/v2 which is v1 - iV2 for some integer i
Syntax:
math.fmod(v1, v2)
Parameters:
Back to top
math.frexp
Available since version: Gideros 2011.6
Description:
and exponent values of v
Syntax:
math.frexp(v)
Parameters:
Back to top
math.ldexp
Available since version: Gideros 2011.6
Description:
returns v1*2^v2
Syntax:
math.ldexp(v1, v2)
Parameters:
Back to top
math.log
Available since version: Gideros 2011.6
Description:
returns natural logarithm of v
Syntax:
math.log(v)
Parameters:
Back to top
math.log10
Available since version: Gideros 2011.6
Description:
returns logarithm 10 of v
Syntax:
math.log10(v)
Parameters:
Back to top
math.max
Available since version: Gideros 2011.6
Description:
returns maximum in a list of one or more values
Syntax:
math.max(v1, ...)
Parameters:
Back to top
math.min
Available since version: Gideros 2011.6
Description:
returns minimum in a list of one or more values
Syntax:
math.min(v1, ...)
Parameters:
Back to top
math.pow
Available since version: Gideros 2011.6
Description:
returns v1 raised to the power of v2
Syntax:
math.pow(v1, v2)
Parameters:
Back to top
math.rad
Available since version: Gideros 2011.6
Description:
returns angle in radians of degrees deg
Syntax:
math.rad(deg)
Parameters:
Back to top
math.random
Available since version: Gideros 2011.6
Description:
Syntax:
math.random(n [, u])
Parameters:
Back to top
math.randomseed
Available since version: Gideros 2011.6
Description:
sets seed for pseudo-random number generator
Syntax:
math.randomseed(seed)
Parameters:
Back to top
math.sin
Available since version: Gideros 2011.6
Description:
returns sine value of angle rad
Syntax:
math.sin(rad)
Parameters:
Back to top
math.sqrt
Available since version: Gideros 2011.6
Description:
returns square root of v
Syntax:
math.sqrt(v)
Parameters:
Back to top
math.tan
Available since version: Gideros 2011.6
Description:
returns tangent value of angle rad
Syntax:
math.tan(rad)
Parameters:
Back to top
huge
Available since version: Gideros 2011.6
Description:
Constant value close to infinity
Value:
huge = "1.#INF"
Back to top
pi
Available since version: Gideros 2011.6
Description:
Constant value of PI
Value:
pi = "3.1415926535898"
Back to top
Matrix
Supported platforms:
Available since version: Gideros 2011.6
Description:
The Matrix class specifies 2D transformation from one coordinate space to another.
These transformations include translation, rotation, scaling and skewing.
A 2D transformation matrix is a 3 x 3 matrix in homogenous coordinate system:

You can get and set the values of all six of the properties in a
Matrix object:
m11
,
m12
,
m21
,
m22
,
tx
, and
ty
.
Back to top
Matrix.new
Available since version: Gideros 2011.6
Description:
Creates a new Matrix object with the specified parameters.
Syntax:
Matrix.new(m11, m12, m21, m22, tx, ty)
Parameters:
- m11: (number, default = 1)
- m12: (number, default = 0)
- m21: (number, default = 0)
- m22: (number, default = 1)
- tx: (number, default = 0)
- ty: (number, default = 0)
Back to top
Matrix:getElements
Available since version: Gideros 2011.6
Description:
Returns the elements of the matrix.
Syntax:
Matrix:getElements()
Back to top
Matrix:getM11
Available since version: Gideros 2011.6
Description:
Returns the value of the
m11
component for this
Matrix instance.
Syntax:
Matrix:getM11()
Back to top
Matrix:getM12
Available since version: Gideros 2011.6
Description:
Returns the value of the
m12
component for this
Matrix instance.
Syntax:
Matrix:getM12()
Back to top
Matrix:getM21
Available since version: Gideros 2011.6
Description:
Returns the value of the
m21
component for this
Matrix instance.
Syntax:
Matrix:getM21()
Back to top
Matrix:getM22
Available since version: Gideros 2011.6
Description:
Returns the value of the
m22
component for this
Matrix instance.
Syntax:
Matrix:getM22()
Back to top
Matrix:getTx
Available since version: Gideros 2011.6
Description:
Returns the value of the
tx
component for this
Matrix instance.
Syntax:
Matrix:getTx()
Back to top
Matrix:getTy
Available since version: Gideros 2011.6
Description:
Returns the value of the
ty
component for this
Matrix instance.
Syntax:
Matrix:getTy()
Back to top
Matrix:setElements
Available since version: Gideros 2011.6
Description:
Sets all 6 elements of the matrix.
Syntax:
Matrix:setElements(m11, m12, m21, m22, tx, ty)
Parameters:
- m11: (number, default = 1)
- m12: (number, default = 0)
- m21: (number, default = 0)
- m22: (number, default = 1)
- tx: (number, default = 0)
- ty: (number, default = 0)
Back to top
Matrix:setM11
Available since version: Gideros 2011.6
Description:
Sets the value of the
m11
component for this
Matrix instance.
Syntax:
Matrix:setM11(m11)
Parameters:
Back to top
Matrix:setM12
Available since version: Gideros 2011.6
Description:
Sets the value of the
m12
component for this
Matrix instance.
Syntax:
Matrix:setM12(m12)
Parameters:
Back to top
Matrix:setM21
Available since version: Gideros 2011.6
Description:
Sets the value of the
m21
component for this
Matrix instance.
Syntax:
Matrix:setM21(m21)
Parameters:
Back to top
Matrix:setM22
Available since version: Gideros 2011.6
Description:
Sets the value of the
m22
component for this
Matrix instance.
Syntax:
Matrix:setM22(m22)
Parameters:
Back to top
Matrix:setTx
Available since version: Gideros 2011.6
Description:
Sets the value of the
tx
component for this
Matrix instance.
Syntax:
Matrix:setTx(tx)
Parameters:
Back to top
Matrix:setTy
Available since version: Gideros 2011.6
Description:
Sets the value of the
ty
component for this
Matrix instance.
Syntax:
Matrix:setTy(ty)
Parameters:
Back to top
Mesh
Supported platforms:
Available since version: Gideros 2012.09
Description:
Mesh class is used to create and display custom constructed set of triangles (triangle meshes). It basically consists of
4 arrays: vertex, index, color (optional), textureCoordinate (optional) and a texture (optional) and it provides more than
one way to set/modify these arrays.
- *Note 1:** Mesh class doesn't do bounds check. If an element at index array points to an non-existent vertex, the application may crash.
Back to top
Mesh.new
Available since version: Gideros 2012.09
Description:
Creates a new
Mesh object.
Syntax:
Mesh.new()
Back to top
Mesh:clearColorArray
Available since version: Gideros 2012.09
Description:
Clears the color array.
Syntax:
Mesh:clearColorArray()
Back to top
Mesh:clearIndexArray
Available since version: Gideros 2012.09
Description:
Clears the index array.
Syntax:
Mesh:clearIndexArray()
Back to top
Mesh:clearTexture
Available since version: Gideros 2012.09
Description:
Clears the texture.
Syntax:
Mesh:clearTexture()
Back to top
Mesh:clearTextureCoordinateArray
Available since version: Gideros 2012.09
Description:
Clears the texture coordinate array.
Syntax:
Mesh:clearTextureCoordinateArray()
Back to top
Mesh:clearVertexArray
Available since version: Gideros 2012.09
Description:
Clears the vertex array.
Syntax:
Mesh:clearVertexArray()
Back to top
Mesh:getColor
Available since version: Gideros 2013.06
Description:
Returns color and alpha of the i-th element from color array
Syntax:
Mesh:getColor(i)
Parameters:
Back to top
Mesh:getColorArraySize
Available since version: Gideros 2013.06
Description:
Get size of the Color array
Syntax:
Mesh:getColorArraySize()
Back to top
Mesh:getIndex
Available since version: Gideros 2013.06
Description:
Returns the i-th element from index array
Syntax:
Mesh:getIndex(i)
Parameters:
Back to top
Mesh:getIndexArraySize
Available since version: Gideros 2013.06
Description:
Get size of the Index array
Syntax:
Mesh:getIndexArraySize()
Back to top
Mesh:getTextureCoordinate
Available since version: Gideros 2013.06
Description:
Returns u and v coordinate of the i-th element from texture coordinate array
Syntax:
Mesh:getTextureCoordinate(i)
Parameters:
Back to top
Mesh:getTextureCoordinateArraySize
Available since version: Gideros 2013.06
Description:
Get size of the Texture Coordinate array
Syntax:
Mesh:getTextureCoordinateArraySize()
Back to top
Mesh:getVertex
Available since version: Gideros 2013.06
Description:
Returns x and y coordinate of the i-th element from vertex array
Syntax:
Mesh:getVertex(i)
Parameters:
Back to top
Mesh:getVertexArraySize
Available since version: Gideros 2013.06
Description:
Get size of the Vertices array
Syntax:
Mesh:getVertexArraySize()
Back to top
Mesh:resizeColorArray
Available since version: Gideros 2012.09
Description:
Resizes the color array to contain size
elements.
If size
is smaller than the current color array size, the content is reduced to its first size
elements, the rest being dropped.
If size
is greater than the current color array size, the content is expanded by inserting at the end as many copies of 0s as needed to reach a size of size
elements.
Syntax:
Mesh:resizeColorArray(size)
Parameters:
- size: (number) new color array size
Back to top
Mesh:resizeIndexArray
Available since version: Gideros 2012.09
Description:
Resizes the index array to contain size
elements.
If size
is smaller than the current index array size, the content is reduced to its first size
elements, the rest being dropped.
If size
is greater than the current index array size, the content is expanded by inserting at the end as many copies of 0s as needed to reach a size of size
elements.
Syntax:
Mesh:resizeIndexArray(size)
Parameters:
- size: (number) new index array size
Back to top
Mesh:resizeTextureCoordinateArray
Available since version: Gideros 2012.09
Description:
Resizes the texture coordinate array to contain size
elements.
If size
is smaller than the current texture coordinate array size, the content is reduced to its first size
elements, the rest being dropped.
If size
is greater than the current texture coordinate array size, the content is expanded by inserting at the end as many copies of 0s as needed to reach a size of size
elements.
Syntax:
Mesh:resizeTextureCoordinateArray(size)
Parameters:
- size: (number) new texture coordinate array size
Back to top
Mesh:resizeVertexArray
Available since version: Gideros 2012.09
Description:
Resizes the vertex array to contain size
elements.
If size
is smaller than the current vertex array size, the content is reduced to its first size
elements, the rest being dropped.
If size
is greater than the current vertex array size, the content is expanded by inserting at the end as many copies of 0s as needed to reach a size of size
elements.
Syntax:
Mesh:resizeVertexArray(size)
Parameters:
- size: (number) new vertex array size
Back to top
Mesh:setColor
Available since version: Gideros 2012.09
Description:
Sets a color at color array. Indices are start from 1. If the color array is not large enough, it's expanded automatically.
Syntax:
Mesh:setColor(i, color, alpha)
Parameters:
- i: (number) index
- color: (number) color in hexedecial value
- alpha: (number, default=1.0) alpha value
Examples:
-- set the first 3 colors as (0xff0000, 0.5), (0x00ff00, 0.7) and (0x0000ff, 1.0).
mesh:setColor(1, 0xff0000, 0.5) -- red with 0.5 alpha
mesh:setColor(2, 0x00ff00, 0.7) -- green with 0.7 alpha
mesh:setColor(3, 0x0000ff) -- blue with 1.0 alpha
Back to top
Mesh:setColorArray
Available since version: Gideros 2012.09
Description:
Assigns new content to the color array, dropping all the elements contained in the color array before the call and replacing them by those specified by the parameters. It accepts multiple values or a Lua array.
Syntax:
Mesh:setColorArray(colors)
Parameters:
Examples:
-- set the color array as (0xff0000, 0.5), (0x00ff00, 0.7) and (0x0000ff, 1.0).
mesh:setColorArray(0xff0000, 0.5, 0x00ff00, 0.7, 0x0000ff, 1.0)
-- same as above
mesh:setColorArray{0xff0000, 0.5, 0x00ff00, 0.7, 0x0000ff, 1.0}
Back to top
Mesh:setColors
Available since version: Gideros 2012.09
Description:
Sets zero or more colors at color array with a single function call. It accepts multiple values or a Lua array.
Syntax:
Mesh:setColors(colors)
Parameters:
Examples:
-- set 3 colors with seperate function calls
mesh:setColor(1, 0xff0000, 0.5)
mesh:setColor(2, 0x00ff00, 0.7)
mesh:setColor(3, 0x0000ff)
-- set 3 colors with one function call
mesh:setColors(1, 0xff0000, 0.5, 2, 0x00ff00, 0.7, 3, 0x0000ff, 1.0)
-- same as above
mesh:setColors{1, 0xff0000, 0.5, 2, 0x00ff00, 0.7, 3, 0x0000ff, 1.0}
-- these two functions do nothing
mesh:setColors()
mesh:setColors{}
Back to top
Mesh:setIndex
Available since version: Gideros 2012.09
Description:
Sets a index at index array. Indices are start from 1. If the index array is not large enough, it's expanded automatically.
Syntax:
Mesh:setIndex(i, index)
Parameters:
- i: (number) index
- index: (number) index
Examples:
-- set the first 3 indices as 10, 11 and 12.
mesh:setIndex(1, 10)
mesh:setIndex(2, 11)
mesh:setIndex(3, 12)
Back to top
Mesh:setIndexArray
Available since version: Gideros 2012.09
Description:
Assigns new content to the index array, dropping all the elements contained in the index array before the call and replacing them by those specified by the parameters. It accepts multiple values or a Lua array.
Syntax:
Mesh:setIndexArray(indices)
Parameters:
Examples:
-- set the index array as 10, 11 and 12.
mesh:setIndexArray(10, 11, 12)
-- same as above
mesh:setIndexArray{10, 11, 12}
Back to top
Mesh:setIndices
Available since version: Gideros 2012.09
Description:
Sets zero or more indices at index array with a single function call. It accepts multiple values or a Lua array.
Syntax:
Mesh:setIndices(indices)
Parameters:
Examples:
-- set 3 indices with seperate function calls
mesh:setIndex(1, 10)
mesh:setIndex(2, 11)
mesh:setIndex(3, 12)
-- set 3 indices with one function call
mesh:setIndices(1, 10, 2, 11, 3, 12)
-- same as above
mesh:setIndices{1, 10, 2, 11, 3, 12}
-- these two functions do nothing
mesh:setIndices()
mesh:setIndices{}
Back to top
Mesh:setTexture
Available since version: Gideros 2012.09
Description:
Sets the texture.
Syntax:
Mesh:setTexture(texture)
Parameters:
Back to top
Mesh:setTextureCoordinate
Available since version: Gideros 2012.09
Description:
Sets a texture coordinate at texture coordinate array. Indices are start from 1. If the texture coordinate array is not large enough, it's expanded automatically.
Syntax:
Mesh:setTextureCoordinate(i, u, v)
Parameters:
- i: (number) index
- u: (number) u coordinate
- v: (number) v coordinate
Examples:
-- set the first 3 texture coordinates as (0, 0), (100, 0) and (0, 100).
mesh:setTextureCoordinate(1, 0, 0)
mesh:setTextureCoordinate(2, 100, 0)
mesh:setTextureCoordinate(3, 0, 100)
Back to top
Mesh:setTextureCoordinateArray
Available since version: Gideros 2012.09
Description:
Assigns new content to the texture coordinate array, dropping all the elements contained in the texture coordinate array before the call and replacing them by those specified by the parameters. It accepts multiple values or a Lua array.
Syntax:
Mesh:setTextureCoordinateArray(textureCoordinates)
Parameters:
Examples:
-- set the color array as (0, 0), (100, 0) and (0, 100)
mesh:setTextureCoordinateArray(0, 0, 100, 0, 0, 100)
-- same as above
mesh:setTextureCoordinateArray{0, 0, 100, 0, 0, 100}
Back to top
Mesh:setTextureCoordinates
Available since version: Gideros 2012.09
Description:
Syntax:
Mesh:setTextureCoordinates(textureCoordinates)
Parameters:
- textureCoordinates: Sets zero or more texture coordinates at texture coordinate array with a single function call. It accepts multiple values or a Lua array.
Examples:
-- set 3 texture coordinates with seperate function calls
mesh:setTextureCoordinate(1, 0, 0)
mesh:setTextureCoordinate(2, 100, 0)
mesh:setTextureCoordinate(3, 0, 100)
-- set 3 texture coordinates with one function call
mesh:setTextureCoordinates(1, 0, 0, 2, 100, 0, 3, 0, 100)
-- same as above
mesh:setTextureCoordinates{1, 0, 0, 2, 100, 0, 3, 0, 100}
-- these two functions do nothing
mesh:setTextureCoordinates()
mesh:setTextureCoordinates{}
Back to top
Mesh:setVertex
Available since version: Gideros 2012.09
Description:
Sets a vertex at vertex array. Indices are start from 1. If the vertex array is not large enough, it's expanded automatically.
Syntax:
Mesh:setVertex(i, x, y)
Parameters:
- i: (number) index
- x: (number) x coordinate
- y: (number) y coordinate
Examples:
-- set the first 3 vertex positions as (100, 100), (150, 100) and (100, 150).
mesh:setVertex(1, 100, 100)
mesh:setVertex(2, 150, 100)
mesh:setVertex(3, 100, 150)
Back to top
Mesh:setVertexArray
Available since version: Gideros 2012.09
Description:
Assigns new content to the vertex array, dropping all the elements contained in the vertex array before the call and replacing them by those specified by the parameters. It accepts multiple values or a Lua array.
Syntax:
Mesh:setVertexArray(vertices)
Parameters:
Examples:
-- set the vertex array as (100, 100), (150, 100) and (100, 150)
mesh:setVertexArray(100, 100, 150, 100, 100, 150)
-- same as above
mesh:setVertexArray{100, 100, 150, 100, 100, 150}
Back to top
Mesh:setVertices
Available since version: Gideros 2012.09
Description:
Sets zero or more vertices at vertex array with a single function call. It accepts multiple values or a Lua array.
Syntax:
Mesh:setVertices(vertices)
Parameters:
Examples:
-- set 3 vertices with seperate function calls
mesh:setVertex(1, 100, 100)
mesh:setVertex(2, 150, 100)
mesh:setVertex(3, 100, 150)
-- set 3 vertices with one function call
mesh:setVertices(1, 100, 100, 2, 150, 100, 3, 100, 150)
-- same as above
mesh:setVertices{1, 100, 100, 2, 150, 100, 3, 100, 150}
-- these two functions do nothing
mesh:setVertices()
mesh:setVertices{}
Back to top
Microphone
Supported platforms:
Available since version: Gideros 2013.06
Description:
Use this plugin to record to an audio clip using a connected microphone.
Installation guide:
Windows
Copy bin/microphone.dll to Plugins directory in your Gideros installation folder
Mac OS X
Copy bin/microphone.dylib to Plugins directory in your Gideros installation folder
iOS
Add gmicrophone-ios.mm, gsoundencoder-wav.cpp and gmicrophonebinder.cpp to Xcode project.
Android
Copy bin/Android/* to libs directory.
Copy source/com/* to your project.
Add System.loadLibrary("microphone"); to your main Activity.
Add "com.giderosmobile.android.plugins.GMicrophone" to externalClasses array.
Add android.permission.RECORD_AUDIO permission to your AndroidManifest.
Back to top
Microphone.new
Available since version: Gideros 2013.06
Description:
Creates a new Microphone object.
Syntax:
Microphone.new(deviceName, sampleRate, numChannels, bitsPerSample)
Parameters:
- deviceName: (string) The name of the device. Passing nil or an empty string will pick the default device.
- sampleRate: (number) Sample rate of the recording. This value should be between 4000 and 44100.
- numChannels: (number) Number of channels. This value can be 1 for mono and 2 for stereo.
- bitsPerSample: (number) Bits per sample. This value can be 8 or 16.
Back to top
Microphone:setOutputFile
Available since version: Gideros 2013.06
Description:
Sets the output file. If an output file is specified, captured audio is recorded to this file. You cannot set output file while recording.
Syntax:
Microphone:setOutputFile(fileName)
Parameters:
- fileName: (string) The filename. It should be on documents or temporary directory.
Back to top
Microphone:start
Available since version: Gideros 2013.06
Description:
Start recording with device.
Syntax:
Microphone:start()
Back to top
Microphone:stop
Available since version: Gideros 2013.06
Description:
Stop recording.
Syntax:
Microphone:stop()
Back to top
Event.DATA_AVAILABLE
Available since version: Gideros 2013.06
Description:
Dispatched as audio samples become available.
Value:
Event.DATA_AVAILABLE = "dataAvailable"
Event properties:
- peakAmplitute: (number) The audio channel's peak amplitute.
- averageAmplitute: (number) The audio channel's average RMS amplitute.
Back to top
MovieClip
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
MovieClip class inherits from the following classes:
Sprite >
EventDispatcher.
The
MovieClip class is used create static timedlined animations. The timeline parameters are given as an array.
Each array element specifies one timeline element and consists of the starting frame, ending frame, sprite and
optional tweening parameters. Frame numbers start from 1.
When a
MovieClip object finishes it playing (by reaching its final frame or a frame with stop action),
it dispatches an
Event.COMPLETE
event.
The following properties can be tweened:
x
y
rotation
scale
scaleX
scaleY
alpha
The following easing functions can be used:
*
"inBack"
*
"outBack"
*
"inOutBack"
*
"inBounce"
*
"outBounce"
*
"inOutBounce"
*
"inCircular"
*
"outCircular"
*
"inOutCircular"
*
"inCubic"
*
"outCubic"
*
"inOutCubic"
*
"inElastic"
*
"outElastic"
*
"inOutElastic"
*
"inExponential"
*
"outExponential"
*
"inOutExponential"
*
"linear"
*
"inQuadratic"
*
"outQuadratic"
*
"inOutQuadratic"
*
"inQuartic"
*
"outQuartic"
*
"inOutQuartic"
*
"inQuintic"
*
"outQuintic"
*
"inOutQuintic"
*
"inSine"
*
"outSine"
*
"inOutSine"
Following examples demonstrates the possible uses of MovieClip class.
Common uses and examples:
-- construct a 100 frame animation where x coordinate of sprite tweens from 0 to 200 linearly
local mc = MovieClip.new{
{1, 100, sprite, {x = {0, 200, "linear"}}}
}
-- construct a 100 frame animation where x coordinate of sprite is 50 (constant) and
-- y coordinate of sprite tweens from 50 to 150 by using inBounce function
local mc = MovieClip.new{
{1, 100, sprite, {x = 50, y = {50, 150, "inBounce"}}}
}
-- construct a 200 frame animation where sprite1 and sprite2 tweens differently
-- here sprite1 is visible between frames [1, 150]
-- and sprite2 is visible between frames [100, 200]
local mc = MovieClip.new{
{1, 100, sprite1, {x = {0, 200, "linear"}}},
{50, 150, sprite1, {y = {0, 100, "linear"}}, {alpha = {0, 1, "easeOut"}}},
{100, 200, sprite2, {x = {0, 200, "linear"}}},
}
-- construct a looping 6 frame animation where each frame is a different sprite
local mc = MovieClip.new{
{1, 1, frame1},
{2, 2, frame2},
{3, 3, frame3},
{4, 4, frame4},
{5, 5, frame5},
{6, 6, frame6},
}
mc:setGotoAction(6, 1) -- if the animation reaches frame 6 then go to frame 1
-- construct a looping 6 frame animation playing 5 times slower than the previous example
local mc = MovieClip.new{
{1, 5, frame1},
{5, 10, frame2},
{11, 15, frame3},
{16, 20, frame4},
{21, 25, frame5},
{26, 30, frame6},
}
mc:setGotoAction(30, 1) -- if the animation reaches frame 30 then go to frame 1
Back to top
MovieClip.new
Available since version: Gideros 2011.6
Description:
Creates a new
MovieClip object. After constructing the MovieClip object, it starts playing. You don't need to
call [[MovieClip:play]].
Syntax:
MovieClip.new(timeline)
Parameters:
- timeline: (table) array of timeline elements
Back to top
MovieClip:clearAction
Available since version: Gideros 2011.6
Description:
Clears the action (goto or stop) at the specified frame.
Syntax:
MovieClip:clearAction(frame)
Parameters:
- frame: (int) the frame number
Back to top
MovieClip:gotoAndPlay
Available since version: Gideros 2011.6
Description:
Goes to the specified frame and starts playing.
Syntax:
MovieClip:gotoAndPlay(frame)
Parameters:
- frame: (int) the frame number
Back to top
MovieClip:gotoAndStop
Available since version: Gideros 2011.6
Description:
Goes to the specified frame and stops.
Syntax:
MovieClip:gotoAndStop(frame)
Parameters:
- frame: (int) the frame number
Back to top
MovieClip:play
Available since version: Gideros 2011.6
Description:
Starts playing the movie clip.
Syntax:
MovieClip:play()
Back to top
MovieClip:setGotoAction
Available since version: Gideros 2011.6
Description:
Sets a *goto* action to the specified frame. When the movie clip reaches a frame
with goto action, it jumps to the destination frame and continues to play.
This function is usually used to create looping animations.
Syntax:
MovieClip:setGotoAction(frame, destframe)
Parameters:
- frame: (int) the frame number
- destframe: (int) the destination frame number
Back to top
MovieClip:setStopAction
Available since version: Gideros 2011.6
Description:
Sets a *stop* action to the specified frame. When the movie clip reaches a frame
with stop action, it stops playing. This function is usually used to divide
the animation into independent parts.
Syntax:
MovieClip:setStopAction(frame)
Parameters:
- frame: (int) the frame number
Back to top
MovieClip:stop
Available since version: Gideros 2011.6
Description:
Stops playing the movie clip.
Syntax:
MovieClip:stop()
Back to top
Event.COMPLETE
Available since version: Gideros 2012.2.1
Description:
This event is dispatched when a
MovieClip object finishes playing (by reaching its final frame or a frame with stop action).
Value:
Event.COMPLETE = "complete"
Back to top
Back to top
os.clock
Available since version: Gideros 2011.6
Description:
returns CPU time used by program in seconds
Syntax:
os.clock()
Back to top
os.date
Available since version: Gideros 2011.6
Description:
returns a string or table containing date and time, "*t" returns a table
Syntax:
os.date(format [, time])
Parameters:
Back to top
os.difftime
Available since version: Gideros 2011.6
Description:
returns number of seconds from time t1 to time t2
Syntax:
os.difftime(t2, t1)
Parameters:
Back to top
os.execute
Available since version: Gideros 2011.6
Description:
executes command using C function system, returns status code
Syntax:
os.execute(command)
Parameters:
Back to top
os.exit
Available since version: Gideros 2011.6
Description:
terminates host program with optional code, default is success code
Syntax:
os.exit(code)
Parameters:
Back to top
os.getenv
Available since version: Gideros 2011.6
Description:
returns value of environment variable varname. nil if not defined
Syntax:
os.getenv(varname)
Parameters:
Back to top
os.remove
Available since version: Gideros 2011.6
Description:
deletes file with given name, nil if fails
Syntax:
os.remove(filename)
Parameters:
Back to top
os.rename
Available since version: Gideros 2011.6
Description:
renames file oldname to newname, nil if fails
Syntax:
os.rename(oldname, newname)
Parameters:
Back to top
os.setlocale
Available since version: Gideros 2011.6
Description:
set current locale of program, returns name of new locate or nil
Syntax:
os.setlocale(locale [, category])
Parameters:
Back to top
os.time
Available since version: Gideros 2011.6
Description:
or time as represented by table
Syntax:
os.time(table)
Parameters:
Back to top
os.timer
Available since version: Gideros 2011.6
Description:
Returns precise time in seconds relative to some arbitrary point.
Syntax:
os.timer()
Back to top
os.tmpname
Available since version: Gideros 2011.6
Description:
Syntax:
os.tmpname()
Back to top
Back to top
package.loadlib
Available since version: Gideros 2011.6
Description:
Syntax:
package.loadlib(libname, funcname)
Parameters:
Back to top
RenderTarget
Supported platforms:
Available since version: Gideros 2013.06
Description:
RenderTarget is a texture on which provided Sprite hierarchy can be rendered.
It can be used in any case in which Texture can be used.
Back to top
RenderTarget.new
Available since version: Gideros 2013.06
Description:
Creates new RenderTarget object
Syntax:
RenderTarget.new(width, height, filtering)
Parameters:
- width: (number) width or rendered texture
- height: (number) height or rendered texture
- filtering: (boolean, default = false) Whether or not the texture is filtered.
Back to top
RenderTarget:clear
Available since version: Gideros 2013.06
Description:
Clears rendered texture with provided color and opacity
Syntax:
RenderTarget:clear(color, alpha)
Parameters:
- color: (number) color using which to clear the texture
- alpha: (number) transparency using which to clear the texture
Back to top
RenderTarget:draw
Available since version: Gideros 2013.06
Description:
Renders provided object or object hierarchy as a texture.
Syntax:
RenderTarget:draw(sprite)
Parameters:
- sprite: (Sprite) any sprite inherited object or object hierarchy to render (this object doesn't need to be added to the stage hierarchy)
Back to top
Shape
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
Shape class is used create and display vector graphics.
Back to top
Shape.new
Available since version: Gideros 2011.6
Description:
Creates a new
Shape object.
Syntax:
Shape.new()
Back to top
Shape:beginPath
Available since version: Gideros 2011.6
Description:
Resets the current path.
Syntax:
Shape:beginPath(winding)
Parameters:
- winding: (string, default = Shape.EVEN_ODD) Specifies the winding rule. It can be either Shape.EVEN_ODD or Shape.NON_ZERO.
Back to top
Shape:clear
Available since version: Gideros 2011.6
Description:
Clears the graphics that were drawn to this
Shape object, and resets fill and line style settings.
Syntax:
Shape:clear()
Back to top
Shape:closePath
Available since version: Gideros 2011.6
Description:
Marks the current subpath as closed, and starts a new subpath with a point the same as the start and end of the newly closed subpath.
Syntax:
Shape:closePath()
Back to top
Shape:endPath
Available since version: Gideros 2011.6
Description:
Ends the current path and draws the geometry by using the specified line and fill styles.
Syntax:
Shape:endPath()
Back to top
Shape:lineTo
Available since version: Gideros 2011.6
Description:
Adds the given point to the current subpath, connected to the previous one by a straight line.
Syntax:
Shape:lineTo(x, y)
Parameters:
- x: (number) x coordinate of the point.
- y: (number) y coordinate of the point.
Back to top
Shape:moveTo
Available since version: Gideros 2011.6
Description:
Creates a new subpath with the given point.
Syntax:
Shape:moveTo(x, y)
Parameters:
- x: (number) x coordinate of the point.
- y: (number) y coordinate of the point.
Back to top
Shape:setFillStyle
Available since version: Gideros 2011.6
Description:
Sets the fill style that
Shape object uses for subsequent drawings. The fill style remains in effect until you call
setFillStyle()
function with different
parameters.
type
parameter can be one of the following values:
- **Shape.NONE:** Clears the fill style.
- **Shape.SOLID:** Sets the fill style as a solid color. In this mode, the parameters are color (in hexedecial value) and an optional alpha value.
- **Shape.TEXTURE:** Sets the fill style as a textured. In this mode, the parameters are texture and an optional transformation matrix.
See the following example for more detailed usage of this function.
Syntax:
Shape:setFillStyle(type, ...)
Parameters:
- type: (string) The type of the fill. Can be one of the Shape.NONE, Shape.SOLID or Shape.TEXTURE.
- ...: Parameters of the fill style.
Examples:
setFillStyle(Shape.NONE) -- clears the fill style
setFillStyle(Shape.SOLID, 0xff0000) -- sets the fill style as solid red color
setFillStyle(Shape.SOLID, 0xff0000, 0.5) -- sets the fill style as solid red color with 0.5 transparency
local texture = Texture.new("image.png")
setFillStyle(Shape.TEXTURE, texture) -- sets the fill style as texture with "image.png"
local matrix = Matrix.new(0.5, 0, 0, 0.5, 0, 0)
setFillStyle(Shape.TEXTURE, texture, matrix) -- sets the fill style as texture with "image.png" with a transformation matrix
Back to top
Shape:setLineStyle
Available since version: Gideros 2011.6
Description:
Sets the line style that
Shape object uses for subsequent drawings. The line style remains in effect until you call
setLineStyle()
function with different
parameters.
Syntax:
Shape:setLineStyle(width, color, alpha)
Parameters:
- width: (number) The width of the line. If this parameter is 0, line is not drawn.
- color: (number, default = 0x000000) A hexadecimal color value of the line. For example, red is 0xFF0000, blue is 0x0000FF, and so on.
- alpha: (number, default = 1) The alpha value of the color of the line.
Back to top
Shape.EVEN_ODD
Available since version: Gideros 2011.6
Description:
Value:
Shape.EVEN_ODD = "evenOdd"
Back to top
Shape.NONE
Available since version: Gideros 2011.6
Description:
Value:
Shape.NONE = "none"
Back to top
Shape.NON_ZERO
Available since version: Gideros 2011.6
Description:
Value:
Shape.NON_ZERO = "nonZero"
Back to top
Shape.SOLID
Available since version: Gideros 2011.6
Description:
Value:
Shape.SOLID = "solid"
Back to top
Shape.TEXTURE
Available since version: Gideros 2011.6
Description:
Value:
Shape.TEXTURE = "texture"
Back to top
Sound
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
Sound class lets you load and play WAV or MP3 sound files.
Control of the playing sound is performed through the
SoundChannel
object.
Common uses and examples:
local sound = Sound.new("music.mp3")
local channel = sound:play()
-- after some time --
channel:stop()
Back to top
Sound.new
Available since version: Gideros 2011.6
Description:
Creates a new
Sound object.
Syntax:
Sound.new(filename)
Parameters:
- filename: (string) The name of the sound file to be loaded.
Back to top
Sound:getLength
Available since version: Gideros 2011.6
Description:
Returns the duration of the sound in miliseconds.
Syntax:
Sound:getLength()
Back to top
Sound:play
Available since version: Gideros 2011.6
Description:
Creates a new
SoundChannel object to play the sound. By using the retured
SoundChannel object,
you can stop the sound and monitor the position.
Syntax:
Sound:play(startTime, looping, paused)
Parameters:
- startTime: (number, default = 0) The initial position in milliseconds at which playback should start.
- looping: (boolean, default = false)
- paused: (boolean, default = false)
Back to top
SoundChannel
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
SoundChannel class is used to control and monitor a playing sound.
SoundChannel Events
- **Event.COMPLETE = "complete"** When the sound channel has finished playing,
Event.COMPLETE
event is dispatched.
Back to top
SoundChannel:getPitch
Available since version: Gideros 2012.09.3
Description:
Returns the current pitch of the sound channel.
Syntax:
SoundChannel:getPitch()
Back to top
SoundChannel:getPosition
Available since version: Gideros 2011.6
Description:
If the sound is playing, getPosition
returns the position of the current playback, measured in miliseconds from the start of the sound.
If the sound is not playing (paused or stopped), getPosition
returns the last point that was played.
Syntax:
SoundChannel:getPosition()
Back to top
SoundChannel:getVolume
Available since version: Gideros 2011.6
Description:
Returns the current volume of the sound channel.
Syntax:
SoundChannel:getVolume()
Back to top
SoundChannel:isLooping
Available since version: Gideros 2011.6
Description:
Returns the looping state of the channel.
Syntax:
SoundChannel:isLooping()
Back to top
SoundChannel:isPaused
Available since version: Gideros 2011.6
Description:
Returns the paused state of the channel.
Syntax:
SoundChannel:isPaused()
Back to top
SoundChannel:isPlaying
Available since version: Gideros 2011.6
Description:
Returns the playing state for the sound channel.
Syntax:
SoundChannel:isPlaying()
Back to top
SoundChannel:setLooping
Available since version: Gideros 2011.6
Description:
Sets the looping state of the channel.
Syntax:
SoundChannel:setLooping(looping)
Parameters:
- looping: (boolean) looping state to set
Back to top
SoundChannel:setPaused
Available since version: Gideros 2011.6
Description:
Sets the paused state of the channel.
Syntax:
SoundChannel:setPaused(paused)
Parameters:
- paused: (boolean) paused state to set
Back to top
SoundChannel:setPitch
Available since version: Gideros 2012.09.3
Description:
Sets the pitch of the sound channel. You cannot set the pitch of a background music.
Syntax:
SoundChannel:setPitch(pitch)
Parameters:
- pitch: (number) The new pitch of the sound channel.
Back to top
SoundChannel:setPosition
Available since version: Gideros 2011.6
Description:
Sets the current playback position in miliseconds.
Syntax:
SoundChannel:setPosition(position)
Parameters:
- position: (number) position of the channel to set in miliseconds
Back to top
SoundChannel:setVolume
Available since version: Gideros 2011.6
Description:
Sets the volume of the sound channel.
Syntax:
SoundChannel:setVolume(volume)
Parameters:
- volume: (number) The new volume of the sound channel. Valid range of this parameter is between 0.0 and 1.0, where 1.0 is the maximum volume value.
Back to top
SoundChannel:stop
Available since version: Gideros 2011.6
Description:
Stops the sound playing in the channel.
Syntax:
SoundChannel:stop()
Back to top
Event.COMPLETE
Available since version: Gideros 2011.6
Description:
This event is dispatched when the sound channel has finished playing.
Value:
Event.COMPLETE = "complete"
Back to top
Sprite
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
Sprite class is the base class for all objects that can be placed on the scene tree. It is the basic scene tree building block.
A sprite can contain child sprites which makes the scene tree hierarchy.
Transformations such as translation, rotation, scaling and color transforms propogates its effect to all of its children.
The drawing order is defined by the order of children. First child is drawn first and last child is drawn last. It is possible to change the drawing order by modifying the order of child list.
A
Sprite instance can exists without attaching the scene tree.
An unattached sprite can receive
Event.ENTER_FRAME
event but it will only receive mouse and touch events when it is attached to the scene tree.
Back to top
Sprite.new
Available since version: Gideros 2011.6
Description:
Creates a new Sprite object
Syntax:
Sprite.new()
Back to top
Sprite:addChild
Available since version: Gideros 2011.6
Description:
Adds a sprite as a child to this sprite. The child is
added as a last child of this
Sprite instance.
Sprites can have only one parent. Therefore if you add a child
object that already has a different sprite as a parent,
the sprite is removed from the child list of the other sprite
and then added to this sprite.
Syntax:
Sprite:addChild(child)
Parameters:
- child: (Sprite) The child sprite to add.
Back to top
Sprite:addChildAt
Available since version: Gideros 2011.6
Description:
Adds a sprite as a child to this sprite. The child is
added at the index position specified. Indices start from 1.
Sprites can have only one parent. Therefore if you add a child
object that already has a different sprite as a parent,
the sprite is removed from the child list of the other sprite
and then added to this sprite.
Syntax:
Sprite:addChildAt(child, index)
Parameters:
- child: (Sprite) The child sprite to add.
- index: (number) The index position to which the child is added.
Back to top
Sprite:clearBlendMode
Available since version: Gideros 2011.6
Description:
Clears the blending mode.
Syntax:
Sprite:clearBlendMode()
Back to top
Sprite:contains
Available since version: Gideros 2011.6
Description:
Determines whether the specified sprite is contained in the subtree of
this
Sprite instance.
Syntax:
Sprite:contains(child)
Parameters:
- child: (Sprite) The child object to test.
Back to top
Sprite:get
Available since version: Gideros 2011.6
Description:
Returns the specified property of this sprite instance by its name. These names are supported:
"x"
"y"
"rotation"
"scaleX"
"scaleY"
"alpha"
"redMultiplier"
"greenMultiplier"
"blueMultiplier"
"alphaMultiplier"
Syntax:
Sprite:get(param)
Parameters:
- param: (string) The name of the parameter
Examples:
-- the following two lines do the same thing
x = sprite:getX()
x = sprite:get("x")
-- the following two lines do the same thing
y = sprite:getY()
y = sprite:get("y")
-- the following two lines do the same thing
rotation = sprite:getRotation()
rotation = sprite:get("rotation")
-- the following two lines do the same thing
scaleX = sprite:getScaleX()
scaleX = sprite:get("scaleX")
-- the following two lines do the same thing
scaleY = sprite:getScaleY()
scaleY = sprite:get("scaleY")
Back to top
Sprite:getAlpha
Available since version: Gideros 2011.6
Description:
Returns the alpha transparency of this sprite. 0 means fully transparent and 1 means fully opaque.
Syntax:
Sprite:getAlpha()
Back to top
Sprite:getBounds
Available since version: Gideros 2011.6
Description:
Returns a rectangle (as x, y, width and height) that encloses the sprite as it appears in another sprite's coordinate system.
Syntax:
Sprite:getBounds(targetSprite)
Parameters:
- targetSprite: (Sprite) the sprite that defines the other coordinate system to transform
Examples:
local x, y, width, height = sprite:getBounds(sprite) -- returns local (untransformed) bounds
local x, y, width, height = sprite:getBounds(stage) -- returns bounds as transformed to stage's coordinate system
Back to top
Sprite:getChildAt
Available since version: Gideros 2011.6
Description:
Returns the child
Sprite instance that exists at the specified index. First child is at index 1.
Syntax:
Sprite:getChildAt(index)
Parameters:
- index: (number) The index position of the child object.
Back to top
Sprite:getChildIndex
Available since version: Gideros 2011.6
Description:
Returns the index of the specified child sprite.
Syntax:
Sprite:getChildIndex(child)
Parameters:
- child: (Sprite) The child sprite to identify.
Back to top
Back to top
Sprite:getHeight
Available since version: Gideros 2011.6
Description:
Returns the height of the sprite, in pixels. The height is calculated based on the
bounds of the content of the sprite.
Syntax:
Sprite:getHeight()
Back to top
Sprite:getMatrix
Available since version: Gideros 2011.6
Description:
Returns the transformation matrix of the sprite. Each invocation of this function returns a new
Matrix object.
Syntax:
Sprite:getMatrix()
Back to top
Sprite:getNumChildren
Available since version: Gideros 2011.6
Description:
Returns the number of children of this sprite.
Syntax:
Sprite:getNumChildren()
Examples:
local container1 = Sprite.new()
local container2 = Sprite.new()
local sprite1 = Sprite.new();
local sprite2 = Sprite.new();
container2:addChild(container1)
container1:addChild(sprite1)
container1:addChild(sprite2)
print(container1:getNumChildren()) --> 2
print(container2:getNumChildren()) --> 1
print(sprite1:getNumChildren()) --> 0
print(sprite2:getNumChildren()) --> 0
Back to top
Sprite:getParent
Available since version: Gideros 2011.6
Description:
Syntax:
Sprite:getParent()
Back to top
Sprite:getPosition
Available since version: Gideros 2011.6
Description:
Returns the x and y coordinates of the sprite.
Syntax:
Sprite:getPosition()
Back to top
Sprite:getRotation
Available since version: Gideros 2011.6
Description:
Returns the rotation of the sprite in degrees.
Syntax:
Sprite:getRotation()
Back to top
Sprite:getScale
Available since version: Gideros 2011.6
Description:
Returns the horizontal and vertical scales of the sprite.
Syntax:
Sprite:getScale()
Back to top
Sprite:getScaleX
Available since version: Gideros 2011.6
Description:
Returns the horizontal scale of the sprite.
Syntax:
Sprite:getScaleX()
Back to top
Sprite:getScaleY
Available since version: Gideros 2011.6
Description:
Returns the vertical scale of the sprite.
Syntax:
Sprite:getScaleY()
Back to top
Sprite:getWidth
Available since version: Gideros 2011.6
Description:
Returns the width of the sprite, in pixels. The width is calculated based on the
bounds of the content of the sprite.
Syntax:
Sprite:getWidth()
Back to top
Sprite:getX
Available since version: Gideros 2011.6
Description:
Returns the x coordinate of the sprite.
Syntax:
Sprite:getX()
Back to top
Sprite:getY
Available since version: Gideros 2011.6
Description:
Returns the y coordinate of the sprite.
Syntax:
Sprite:getY()
Back to top
Sprite:globalToLocal
Available since version: Gideros 2011.6
Description:
Converts the x,y coordinates from the global to the sprite's (local) coordinates.
Syntax:
Sprite:globalToLocal(x, y)
Parameters:
- x: (number) x coordinate of the global coordinate.
- y: (number) y coordinate of the global coordinate.
Back to top
Sprite:hitTestPoint
Available since version: Gideros 2011.6
Description:
Checks whether the given coordinates (in global coordinate system) is in bounds of the sprite.
Syntax:
Sprite:hitTestPoint(x, y)
Parameters:
Back to top
Sprite:isVisible
Available since version: Gideros 2011.6
Description:
Returns whether or not the sprite is visible. Child sprites that are not visible are also taken
into consideration while calculating bounds.
Syntax:
Sprite:isVisible()
Back to top
Sprite:localToGlobal
Available since version: Gideros 2011.6
Description:
Converts the x,y coordinates from the sprite's (local) coordinates to the global coordinates.
Syntax:
Sprite:localToGlobal(x, y)
Parameters:
- x: (number) x coordinate of the local coordinate.
- y: (number) y coordinate of the local coordinate.
Back to top
Sprite:removeChild
Available since version: Gideros 2011.6
Description:
Removes the specified child
Sprite instance from the child list of this
Sprite instance.
Syntax:
Sprite:removeChild(child)
Parameters:
- child: (Sprite) The child sprite to remove.
Back to top
Sprite:removeChildAt
Available since version: Gideros 2011.6
Description:
Removes the child
Sprite instance at the specifed index. Index of the first child is 1
and index of the last child can be get from
Sprite:getNumChildren
function.
Syntax:
Sprite:removeChildAt(index)
Parameters:
- index: (number) The child index of the sprite to remove.
Back to top
Sprite:removeFromParent
Available since version: Gideros 2011.6
Description:
If the sprite has a parent, removes the sprite from the child list of its parent sprite. This function is equilavent to:
function Sprite:removeFromParent()
local parent = self:getParent()
if parent ~= nil then
parent:removeChild(self)
end
end
Syntax:
Sprite:removeFromParent()
Back to top
Sprite:set
Available since version: Gideros 2011.6
Description:
Sets the specified property of this sprite instance by its name. These names are supported:
"x"
"y"
"rotation"
"scaleX"
"scaleY"
"scale"
"alpha"
"redMultiplier"
"greenMultiplier"
"blueMultiplier"
"alphaMultiplier"
Syntax:
Sprite:set(param, value)
Parameters:
- param: (string) The name of the parameter
- value: (number) The new value of the specified parameter
Examples:
-- the following two lines do the same thing
sprite:setX(10)
sprite:set("x", 10)
-- the following two lines do the same thing
sprite:setY(10)
sprite:set("y", 10)
-- the following two lines do the same thing
sprite:setRotation(10)
sprite:set("rotation", 10)
-- the following two lines do the same thing
sprite:setScaleX(0.5)
sprite:set("scaleX", 0.5)
-- the following two lines do the same thing
sprite:setScaleY(0.5)
sprite:set("scaleY", 0.5)
-- the following two lines do the same thing
sprite:setScale(0.5)
sprite:set("scale", 0.5)
Back to top
Sprite:setAlpha
Available since version: Gideros 2011.6
Description:
Sets the alpha transparency of this sprite. 0 means fully transparent and 1 means fully opaque.
Syntax:
Sprite:setAlpha(alpha)
Parameters:
- alpha: (number) The new alpha transparency of the sprite
Back to top
Sprite:setBlendMode
Available since version: Gideros 2011.6
Description:
Sets the blend mode of the sprite. Currently supported blending modes are:
- Sprite.ALPHA = "alpha"
- Sprite.NO_ALPHA = "noAlpha"
- Sprite.ADD = "add"
- Sprite.MULTIPLY = "multiply"
- Sprite.SCREEN = "screen"
If a
Sprite object doesn't set any blending mode, it takes the blending mode from its parent sprite.
- *Note:** The following two lines are completely same:
sprite:setBlendMode("add")
sprite:setBlendMode(Sprite.ADD)
It's a matter of taste which one to choose.
Syntax:
Sprite:setBlendMode(blendMode)
Parameters:
Back to top
Back to top
Sprite:setMatrix
Available since version: Gideros 2011.6
Description:
Sets the transformation matrix of the sprite.
Syntax:
Sprite:setMatrix(matrix)
Parameters:
Back to top
Sprite:setPosition
Available since version: Gideros 2011.6
Description:
Sets the x and y coordinates of the sprite.
Syntax:
Sprite:setPosition(x, y)
Parameters:
- x: (number) The new x coordinate of the sprite
- y: (number) The new y coordinate of the sprite
Back to top
Sprite:setRotation
Available since version: Gideros 2011.6
Description:
Sets the rotation of the sprite in degrees.
Syntax:
Sprite:setRotation(rotation)
Parameters:
- rotation: (number) rotation of the sprite
Back to top
Sprite:setScale
Available since version: Gideros 2011.6
Description:
Sets the horizontal and vertical scales of the sprite.
Syntax:
Sprite:setScale(scaleX, scaleY)
Parameters:
- scaleX: (number) of the object
- scaleY: (number, default = scaleX) of the object
Back to top
Sprite:setScaleX
Available since version: Gideros 2011.6
Description:
Sets the horizontal scale of the sprite.
Syntax:
Sprite:setScaleX(scaleX)
Parameters:
- scaleX: (number) horizontal scale of the sprite
Back to top
Sprite:setScaleY
Available since version: Gideros 2011.6
Description:
Sets the vertical scale of the sprite.
Syntax:
Sprite:setScaleY(scaleY)
Parameters:
- scaleY: (number) of the object
Back to top
Sprite:setVisible
Available since version: Gideros 2011.6
Description:
Sets whether or not the sprite is visible. Sprites that are not visible are also taken
into consideration while calculating bounds.
Syntax:
Sprite:setVisible(visible)
Parameters:
- visible: (bool) whether or not the sprite is visible
Back to top
Sprite:setX
Available since version: Gideros 2011.6
Description:
Sets the x coordinate of the sprite
Syntax:
Sprite:setX(x)
Parameters:
- x: (number) The new x coordinate of the sprite
Back to top
Sprite:setY
Available since version: Gideros 2011.6
Description:
Sets the y coordinate of the sprite.
Syntax:
Sprite:setY(y)
Parameters:
- y: (number) The new y coordinate of the sprite
Back to top
Event.ADDED_TO_STAGE
Available since version: Gideros 2011.6
Description:
This event is dispatched when object is added to the stage hierarchy
Value:
Event.ADDED_TO_STAGE = "addedToStage"
Back to top
Event.ENTER_FRAME
Available since version: Gideros 2011.6
Description:
The Gideros runtime dispatches the built-in
Event.ENTER_FRAME
event to
Sprite instances before rendering the screen. Visual changes made by any
Event.ENTER_FRAME
listener function will be visible at next frame.
Value:
Event.ENTER_FRAME = "enterFrame"
Event properties:
- deltaTime: (number) time passed from previous frame
- time: (number) time passed from app start
- frameCount: (number) frame count from app start
Back to top
Event.KEY_DOWN
Available since version: Gideros 2011.6
Description:
This event is dispatched when a supported key is pressed. For the list of supported keys, check
KeyCode class.
Value:
Event.KEY_DOWN = "keyDown"
Event properties:
- keyCode: (number) code of the key pressed.
Back to top
Event.KEY_UP
Available since version: Gideros 2011.6
Description:
This event is dispatched when a supported key is released. For the list of supported keys, check
KeyCode class.
Value:
Event.KEY_UP = "keyUp"
Event properties:
- keyCode: (number) code of the key pressed.
Back to top
Event.MOUSE_DOWN
Available since version: Gideros 2011.6
Description:
This event is dispatched on mouse down action. It is possible to generate this event using touch actions, by enabling this option through project settings.
Value:
Event.MOUSE_DOWN = "mouseDown"
Event properties:
- x: (number) x coordinate of the click
- y: (number) y coordinate of the click
- rx: (number) unrounded x coordinate of the click
- ry: (number) unrounded y coordinate of the click
Back to top
Event.MOUSE_MOVE
Available since version: Gideros 2011.6
Description:
This event is dispatched when mouse is moved. It is possible to generate this event using touch actions, by enabling this option through project settings.
Value:
Event.MOUSE_MOVE = "mouseMove"
Event properties:
- x: (number) x coordinate of the click
- y: (number) y coordinate of the click
- rx: (number) unrounded x coordinate of the click
- ry: (number) unrounded y coordinate of the click
Back to top
Event.MOUSE_UP
Available since version: Gideros 2011.6
Description:
This event is dispatched when mouse button is released. It is possible to generate this event using touch actions, by enabling this option through project settings.
Value:
Event.MOUSE_UP = "mouseUp"
Event properties:
- x: (number) x coordinate of the click
- y: (number) y coordinate of the click
- rx: (number) unrounded x coordinate of the click
- ry: (number) unrounded y coordinate of the click
Back to top
Event.REMOVED_FROM_STAGE
Available since version: Gideros 2011.6
Description:
This event is dispatched when object is removed from stage hierarchy
Value:
Event.REMOVED_FROM_STAGE = "removedFromStage"
Back to top
Event.TOUCHES_BEGIN
Available since version: Gideros 2011.6
Description:
This event is dispatched on touch begin action. It is possible to generate this event using mouse actions, by enabling this option through project settings.
Value:
Event.TOUCHES_BEGIN = "touchesBegin"
Event properties:
- touch.x: (number) x coordinate of the current touch
- touch.y: (number) y coordinate of the current touch
- touch.rx: (number) unrounded x coordinate of the touch
- touch.ry: (number) unrounded y coordinate of the touch
- touch.id: (number) the id of current touch. This number is 1 if this is a first touch, 2 if it is a second, etc.
- allTouches: (table) lua table containing previously described touch table with x, y, rx, ry and id properties for all touches that are currently on device.
Back to top
Event.TOUCHES_CANCEL
Available since version: Gideros 2011.6
Description:
This event is dispatched when touch is interrupted, for example, by a phone call, or any sort of modal dialog.
This event is dispatched only on devices.
Value:
Event.TOUCHES_CANCEL = "touchesCancel"
Event properties:
- touch.x: (number) x coordinate of the current touch
- touch.y: (number) y coordinate of the current touch
- touch.rx: (number) unrounded x coordinate of the touch
- touch.ry: (number) unrounded y coordinate of the touch
- touch.id: (number) the id of current touch. This number is 1 if this is a first touch, 2 if it is a second, etc.
- allTouches: (table) lua table containing previously described touch table with x, y, rx, ry and id properties for all touches that are currently on device.
Back to top
Event.TOUCHES_END
Available since version: Gideros 2011.6
Description:
This event is dispatched then touch is ended. It is possible to generate this event using mouse actions, by enabling this option through project settings.
Value:
Event.TOUCHES_END = "touchesEnd"
Event properties:
- touch.x: (number) x coordinate of the current touch
- touch.y: (number) y coordinate of the current touch
- touch.rx: (number) unrounded x coordinate of the touch
- touch.ry: (number) unrounded y coordinate of the touch
- touch.id: (number) the id of current touch. This number is 1 if this is a first touch, 2 if it is a second, etc.
- allTouches: (table) lua table containing previously described touch table with x, y, rx, ry and id properties for all touches that are currently on device.
Back to top
Event.TOUCHES_MOVE
Available since version: Gideros 2011.6
Description:
This event is dispatched on touch move action. It is possible to generate this event using mouse actions, by enabling this option through project settings.
Value:
Event.TOUCHES_MOVE = "touchesMove"
Event properties:
- touch.x: (number) x coordinate of the current touch
- touch.y: (number) y coordinate of the current touch
- touch.rx: (number) unrounded x coordinate of the touch
- touch.ry: (number) unrounded y coordinate of the touch
- touch.id: (number) the id of current touch. This number is 1 if this is a first touch, 2 if it is a second, etc.
- allTouches: (table) lua table containing previously described touch table with x, y, rx, ry and id properties for all touches that are currently on device.
Back to top
Sprite.ADD
Available since version: Gideros 2011.6
Description:
Value:
Sprite.ADD = "add"
Back to top
Sprite.ALPHA
Available since version: Gideros 2011.6
Description:
Value:
Sprite.ALPHA = "alpha"
Back to top
Sprite.MULTIPLY
Available since version: Gideros 2011.6
Description:
Value:
Sprite.MULTIPLY = "multiply"
Back to top
Sprite.NO_ALPHA
Available since version: Gideros 2011.6
Description:
Value:
Sprite.NO_ALPHA = "noAlpha"
Back to top
Sprite.SCREEN
Available since version: Gideros 2011.6
Description:
Value:
Sprite.SCREEN = "screen"
Back to top
sqlite3
Supported platforms:
Available since version: Gideros 2012.2.1
Description:
Gideros runtime supports public domain SQLite3 database engine for iOS, Android and Desktop platforms.
For more information and detailed documentation, please visit
http://lua.sqlite.org.
SQLite3 on Android platforms
Currently, LuaSQLite3 plugin cannot open databases stored in APK files. Therefore, database file should be
copied from resource directory to documents directory.
To copy a file, this function can be used:
local function copy(src, dst)
local srcf = io.open(src, "rb")
local dstf = io.open(dst, "wb")
local size = 2^13 -- good buffer size (8K)
while true do
local block = srcf:read(size)
if not block then break end
dstf:write(block)
end
srcf:close()
dstf:close()
end
Also it's better to check if the database file is previously copied or not. To check if a file can be found
on the underlying file system, this function can be used:
local function exists(file)
local f = io.open(file, "rb")
if f == nil then
return false
end
f:close()
return true
end
By using these two function, you can copy the database file from resource to documents directory before using it:
if not exists("|D|database.db") then
copy("database.db", "|D|database.db")
end
Back to top
Stage
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
Stage class represents the top of the scene tree hierarchy. The instances of
Stage is not created directly (there is not any
Stage.new
function) but
there is already a global variable
stage.
Back to top
StoreKit
Supported platforms:
Available since version: Gideros 2012.2.2
Description:
The
StoreKit class provides the functionality that allow an application to request payment from a user.
This class is only available to iOS platforms.
The
StoreKit class is defined in module "storekit". Therefore, you need to call
require("storekit")
before using it. Loading the "storekit" module
also creates a global variable
storekit of type
StoreKit for direct use.
State of a Transaction
The state of a transaction is defined by 3 string constants:
- **StoreKit.PURCHASED = "purchased"**: The App Store successfully processed payment. Your application should provide the content the user purchased.
- **StoreKit.FAILED = "failed"**: The transaction failed. Check the
event.errorCode
and event.errorDescription
fields to determine what happened.
- **StoreKit.RESTORED = "restored"**: This transaction restores content previously purchased by the user. Read the
event.originalTransaction
field to obtain information about the original purchase.
StoreKit Events
The
StoreKit class dispatches the events
Event.REQUEST_PRODUCTS_COMPLETE
,
Event.TRANSACTION
and
Event.RESTORE_TRANSACTIONS_COMPLETE
.
# Event.REQUEST_PRODUCTS_COMPLETE
The function [[StoreKit:requestProducts]] is used to retrieve localized information about a list of products from the Apple App Store.
When the request completes,
Event.REQUEST_PRODUCTS_COMPLETE
event is dispatched. The resulting event table contains
these additional fields about the products:
- **event.error:** (number) error code if the request failed to execute
- **event.errorDescription:** (string) error description if the request failed to execute
- **event.products:** (table) array of products where each element is a table which contains the product information
- **event.invalidProductIdentifiers:** (table) array of product identifier strings that were not recognized by the Apple App Store
Each table in
event.products
array contains these fields:
- **title:** (number) localized name of the product
- **description:** (string) localized description of the product
- **price:** (number) cost of the product in the local currency
- **productIdentifier:** (string) string that identifies the product to the Apple App Store
For example, this code can be used to print the retrieved product information:
local function onRequestProductsComplete(event)
if event.errorCode ~= nil then
print("error", event.errorCode, event.errorDescription)
return
end
print("products:")
for i=1,#event.products do
print("title", event.products[i].title)
print("description", event.products[i].description)
print("price", event.products[i].price)
print("productIdentifier", event.products[i].productIdentifier)
end
print("invalidProductIdentifiers:")
for i=1,#event.invalidProductIdentifiers do
print(event.invalidProductIdentifiers[i])
end
end
# Event.TRANSACTION
This event is dispatched when a transaction is updated. The event listener should process all successful transactions,
unlock the functionality purchased by the user, and then finish the transaction by calling [[StoreKit:finishTransaction]] method. The resulting event table can
contain these additional fields about the products:
- **event.errorCode:** (number) error code if
event.transaction.state
is set to StoreKit.FAILED
- **event.errorDescription:** (string) error description if
event.transaction.state
is set to StoreKit.FAILED
- **event.payment.productIdentifier:** (string) product identifier of the transaction
- **event.payment.quantity:** (number) number of items the user wants to purchase
- **event.transaction.state:** (string) current state of the transaction
- **event.transaction.identifier:** (string) string that uniquely identifies a successful payment transaction
- **event.transaction.receipt:** (string) signed receipt that records all information about a successful payment transaction
- **event.transaction.date:** (string) date the transaction was added to the App Store's payment queue
- **event.originalTransaction.identifier:** (string) identifier of original transaction
- **event.originalTransaction.date:** (string) date of the original transaction
This code can be used to print the transaction information and unlock the functionality purchased by the user:
local function onTransaction(event)
print("payment.productIdentifier", event.payment.productIdentifier)
print("payment.quantity", event.payment.quantity)
print("transaction.state", event.transaction.state)
if event.transaction.state == StoreKit.FAILED then
print("error", event.errorCode, event.errorDescription)
else
print("transaction.identifier", event.transaction.identifier)
print("transaction.date", event.transaction.date)
if event.transaction.state == StoreKit.PURCHASED then
print("transaction.receipt", event.transaction.receipt)
end
if event.transaction.state == StoreKit.RESTORED then
print("originalTransaction.identifier", event.originalTransaction.identifier)
print("originalTransaction.date", event.originalTransaction.date)
end
-- unlock the functionality purchased by the user
end
storekit:finishTransaction(event.transaction)
end
# Event.RESTORE_TRANSACTIONS_COMPLETE
This event is dispatched after the transactions are delivered. The resulting event table can contain these additional fields:
- **event.errorCode:** (number) error code if an error occurred while restoring transactions
- **event.errorDescription:** (string) description of the error if an error occurred while restoring transactions
If all transactions are delivered successfully,
event.errorCode
and
event.errorDescription
will be
nil
.
Back to top
StoreKit:canMakePayments
Available since version: Gideros 2012.2.2
Description:
Returns whether the user is allowed to make payments.
Syntax:
StoreKit:canMakePayments()
Back to top
StoreKit:finishTransaction
Available since version: Gideros 2012.2.2
Description:
Completes a pending transaction. Your application should call this function only after it has successfully processed the transaction and unlocked the functionality
purchased by the user.
Syntax:
StoreKit:finishTransaction(transaction)
Parameters:
- transaction: (table) transaction information recevied with the event Event.TRANSACTION.
Back to top
StoreKit:purchase
Available since version: Gideros 2012.2.2
Description:
Process a payment request. When that transaction is complete or if a failure occurs, Event.TRANSACTION
event is dispatched.
Syntax:
StoreKit:purchase(productIdentifier, quantity)
Parameters:
- productIdentifier: (string) A string used to identify a product that can be purchased from within your application.
- quantity: (number, default = 1) The number of items the user wants to purchase. This value should be greater than or equal to 1.
Back to top
StoreKit:requestProducts
Available since version: Gideros 2012.2.2
Description:
Retrieve localized information about a list of products from the Apple App Store. When the request completes, Event.REQUEST_PRODUCTS_COMPLETE
event is dispatched.
Syntax:
StoreKit:requestProducts(productIdentifiers)
Parameters:
- productIdentifiers: (table) An array of product identifiers for the products you wish to retrieve descriptions of.
Back to top
StoreKit:restoreCompletedTransactions
Available since version: Gideros 2012.2.2
Description:
Restore previously completed purchases. Event.TRANSACTION
event is dispatched for each previously completed transaction that can be restored.
Each transaction includes a copy of the original transaction.
After the transactions are delivered, Event.RESTORE_TRANSACTIONS_COMPLETE
event is dispatched. If an error occurred while restoring transactions, event.errorCode
and
event.errorDescription
fields contain the details of the error.
Syntax:
StoreKit:restoreCompletedTransactions()
Back to top
Event.REQUEST_PRODUCTS_COMPLETE
Available since version: Gideros 2012.2.2
Description:
This event is dispatched after the method StoreKit:requestProducts
is called and completed request. It provides information about products available.
Value:
Event.REQUEST_PRODUCTS_COMPLETE = "requestProductsComplete"
Event properties:
- error: (number) error code if the request failed to execute
- errorDescription: (string) error description if the request failed to execute
- invalidProductIdentifiers: (table) array of product identifier strings that were not recognized by the Apple App Store
- products: (table) array of products where each element is a table which contains the product information
- products[].title: (string) localized name of the product
- products[].description: (string) localized description of the product
- products[].price: (price) cost of the product in the local currency
- products[].productIdentifier: (string) string that identifies the product in the Apple App Store
Back to top
Event.RESTORE_TRANSACTIONS_COMPLETE
Available since version: Gideros 2012.2.2
Description:
This event is dispatched after call of StoreKit:restoreCompletedTransactions
and when it's request is completed.
Value:
Event.RESTORE_TRANSACTIONS_COMPLETE = "restoreTransactionsComplete"
Event properties:
- errorCode: (number) error code if an error occurred while restoring transactions
- errorDescription: (string) description of the error if an error occurred while restoring transactions
Back to top
Event.TRANSACTION
Available since version: Gideros 2012.2.2
Description:
This event is dispatched when a transaction is updated. The event listener should process all successful transactions, unlock the functionality purchased by the user, and then finish the transaction by calling StoreKit:finishTransaction
method.
Value:
Event.TRANSACTION = "transaction"
Event properties:
- errorCode: (number) error code if the request failed to execute and event.transaction.state is set to StoreKit.FAILED
- errorDescription: (string) error description if the request failed to execute and event.transaction.state is set to StoreKit.FAILED
- payment.productIdentifier: (string) product identifier for this transaction
- payment.quantity: (number) number of items the user wants to purchase
- transaction.state: (string) current state of the transaction
- transaction.identifier: (string) string that uniquely identifies a successful payment transaction
- transaction.receipt: (string) signed receipt that records all information about a successful payment transaction
- transaction.date: (string) date the transaction was added to the App Store’s payment queue
- originalTransaction.identifier: (string) identifier of original transaction
- originalTransaction.date: (string) date of the original transaction
Back to top
StoreKit.FAILED
Available since version: Gideros 2012.2.2
Description:
The transaction failed. Check the event.errorCode
and event.errorDescription
fields to determine what happened.
Value:
StoreKit.FAILED = "failed"
Back to top
StoreKit.PURCHASED
Available since version: Gideros 2012.2.2
Description:
Indicates the state of the purchase as purchased. You can unlock content at this state.
Value:
StoreKit.PURCHASED = "purchased"
Back to top
StoreKit.RESTORED
Available since version: Gideros 2012.2.2
Description:
This transaction restores content previously purchased by the user. Read the event.originalTransaction
field to obtain information about the original purchase.
Value:
StoreKit.RESTORED = "restored"
Back to top
Back to top
string.byte
Available since version: Gideros 2011.6
Description:
returns numerical code, nil if index out of range, default i=1
Syntax:
string.byte(s [, i])
Parameters:
Back to top
string.char
Available since version: Gideros 2011.6
Description:
returns a string built from 0 or more integers
Syntax:
string.char(i1, i2, ...)
Parameters:
Back to top
string.dump
Available since version: Gideros 2011.6
Description:
returns binary representation of function, used with loadstring
Syntax:
string.dump(function)
Parameters:
Back to top
string.find
Available since version: Gideros 2011.6
Description:
matches pattern in s, returns start,end indices, else nil
Syntax:
string.find(s, pattern [, init, plain])
Parameters:
Back to top
Back to top
string.gmatch
Available since version: Gideros 2011.6
Description:
returns iterator function that returns next captures from pattern pat on s
Syntax:
string.gmatch(s, pat)
Parameters:
Back to top
string.gsub
Available since version: Gideros 2011.6
Description:
returns copy of s with pat replaced by repl, and substitutions made
Syntax:
string.gsub(s, pat, repl [, n])
Parameters:
Back to top
string.len
Available since version: Gideros 2011.6
Description:
returns string length
Syntax:
string.len(s)
Parameters:
Back to top
string.lower
Available since version: Gideros 2011.6
Description:
returns string with letters in lower case
Syntax:
string.lower(s)
Parameters:
Back to top
string.rep
Available since version: Gideros 2011.6
Description:
returns string with n copies of string s
Syntax:
string.rep(s, n)
Parameters:
Back to top
string.sub
Available since version: Gideros 2011.6
Description:
Syntax:
string.sub(s, i [, j])
Parameters:
Back to top
string.upper
Available since version: Gideros 2011.6
Description:
returns string with letters in upper case
Syntax:
string.upper(s)
Parameters:
Back to top
Back to top
table.concat
Available since version: Gideros 2011.6
Description:
returns concatenated table elements i to j separated by sep
Syntax:
table.concat(table [, sep, i, j])
Parameters:
Back to top
table.getn
Available since version: Gideros 2011.6
Description:
returns size of table, or n field, or table.setn value, or 1 less first index with nil value\n [Deprecated in Lua 5.1, use # operator]
Syntax:
table.getn(table)
Parameters:
Back to top
table.insert
Available since version: Gideros 2011.6
Description:
insert value at location pos in table, default pos=n 1
Syntax:
table.insert(table, pos [, value])
Parameters:
Back to top
table.remove
Available since version: Gideros 2011.6
Description:
removes element at pos from table, default pos=n
Syntax:
table.remove(table [, pos])
Parameters:
Back to top
table.sort
Available since version: Gideros 2011.6
Description:
true if v1
Syntax:
table.sort(table [, comp])
Parameters:
Back to top
TextField
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
TextField class is used to create display objects for text display.
Common uses and examples:
local font = Font.new("myfont.txt", "myfont.png")
local textfield = TextField.new(font, "some text")
stage:addChild(textfield)
textfield:setText("some other text") -- change the text
-- to use the default font, pass nil value for the font parameter
local textfield2 = TextField.new(nil, "some other text with default font")
Back to top
TextField.new
Available since version: Gideros 2011.6
Description:
Creates a new
TextField object with the specified font and text. Gideros runtime includes a
default font. If you specify
nil
for the font parameter while creating the
TextField object, default font is used.
Syntax:
TextField.new(font, text)
Parameters:
- font: (FontBase) The font used for displaying this `TextField` object. If nil, default font is used.
- text: (string, optional) The text to be displayed.
Back to top
TextField:getLetterSpacing
Available since version: Gideros 2011.6
Description:
Returns the letter-spacing property which is used to increase or decrease the space between characters in a text.
Syntax:
TextField:getLetterSpacing()
Back to top
TextField:getText
Available since version: Gideros 2011.6
Description:
Returns the text displayed.
Syntax:
TextField:getText()
Back to top
TextField:getTextColor
Available since version: Gideros 2011.6
Description:
Syntax:
TextField:getTextColor()
Back to top
TextField:setLetterSpacing
Available since version: Gideros 2011.6
Description:
Sets the letter-spacing property which is used to increase or decrease the space between characters in a text.
Syntax:
TextField:setLetterSpacing(spacing)
Parameters:
Back to top
TextField:setText
Available since version: Gideros 2011.6
Description:
Sets the text to be displayed.
Syntax:
TextField:setText(text)
Parameters:
- text: (string) The text to be displayed.
Back to top
TextField:setTextColor
Available since version: Gideros 2011.6
Description:
Sets the color of the text in a text field in hexadecimal format.
Syntax:
TextField:setTextColor(color)
Parameters:
- color: (number) color of the text in hexadecimal format.
Examples:
textfield:setTextColor(0xff0000) -- red
textfield:setTextColor(0x00ff00) -- green
textfield:setTextColor(0x0000ff) -- blue
Back to top
TextInputDialog
Supported platforms:
Available since version: Gideros 2012.8
Description:
The
TextInputDialog class is used to display native text input dialogs with one text edit field, one button (as cancel button) and two optional buttons. When the user presses any buttons in the alert dialog, it's dismissed and
Event.COMPLETE
event is dispatched.
If text input dialog is dismissed by any other means (by pressing back button on Android or by pressing close button on desktop), it behaves as cancel button is pressed.
Common uses and examples:
local textInputDialog = TextInputDialog.new("my title", "my message", "some text", "Cancel", "OK")
local function onComplete(event)
print(event.text, event.buttonIndex, event.buttonText)
end
textInputDialog:addEventListener(Event.COMPLETE, onComplete)
textInputDialog:show()
Back to top
TextInputDialog.new
Available since version: Gideros 2012.8
Description:
Syntax:
TextInputDialog.new(title, message, text, cancelButton, button1, button2)
Parameters:
- title: (string)
- message: (string) Descriptive text that provides more details than the title.
- text: (string) The text on the text field.
- cancelButton: (string) The text of the cancel button.
- button1: (string, optional) The text of the 1st optional button.
- button2: (string, optional) The text of the 2st optional button.
Back to top
TextInputDialog:getInputType
Available since version: Gideros 2012.8
Description:
Returns the keyboard type associated with the text field.
Syntax:
TextInputDialog:getInputType()
Back to top
TextInputDialog:getText
Available since version: Gideros 2012.8
Description:
Returns the text on the text field.
Syntax:
TextInputDialog:getText()
Back to top
TextInputDialog:isSecureInput
Available since version: Gideros 2012.8
Description:
Returns whether the text object hides the text being entered.
Syntax:
TextInputDialog:isSecureInput()
Back to top
TextInputDialog:setInputType
Available since version: Gideros 2012.8
Description:
Sets the input (keyboard) type associated with the text field. The options are:
TextInputDialog.TEXT
: Default keyboard type
TextInputDialog.NUMBER
: Numeric keypad
TextInputDialog.PHONE
: Keypad designed for entering telephone numbers
TextInputDialog.EMAIL
: Keyboard optimized for specifying email addresses
TextInputDialog.URL
: Keyboard optimized for URL entry
Syntax:
TextInputDialog:setInputType(type)
Parameters:
- type: (string) Tnput type associated with the text field.
Back to top
TextInputDialog:setSecureInput
Available since version: Gideros 2012.8
Description:
Sets whether the text object should hide the text being entered.
Syntax:
TextInputDialog:setSecureInput(secureInput)
Parameters:
- secureInput: (boolean) If 'true', the text object hides the text being entered.
Back to top
TextInputDialog:setText
Available since version: Gideros 2012.8
Description:
Sets the text on the text field.
Syntax:
TextInputDialog:setText(text)
Parameters:
- text: (string) The text on the text field.
Back to top
Event.COMPLETE
Available since version: Gideros 2012.8
Description:
This event is dispatched when user presses any button on TextInputDialog or the dialog is dismissed by any other reason.
Value:
Event.COMPLETE = "complete"
Event properties:
- text: (string) the text entered into text input field
- buttonIndex: (number) the index of the button pressed. It is nil when cancel button is pressed, 1 when 1st button is pressed and 2 when 2nd button is pressed.
- buttonText: (string) the text of the button pressed
Back to top
TextInputDialog.EMAIL
Available since version: Gideros 2011.6
Description:
Value:
TextInputDialog.EMAIL = "email"
Back to top
TextInputDialog.NUMBER
Available since version: Gideros 2011.6
Description:
Value:
TextInputDialog.NUMBER = "number"
Back to top
TextInputDialog.PHONE
Available since version: Gideros 2011.6
Description:
Value:
TextInputDialog.PHONE = "phone"
Back to top
TextInputDialog.TEXT
Available since version: Gideros 2011.6
Description:
Value:
TextInputDialog.TEXT = "text"
Back to top
TextInputDialog.URL
Available since version: Gideros 2011.6
Description:
Value:
TextInputDialog.URL = "url"
Back to top
Texture
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
Texture class lets you work with textures in an application. The
Texture class lets you create
a new
Texture object to load from an image file and display in scene tree.
Back to top
Texture.new
Available since version: Gideros 2011.6
Description:
Creates a new Texture object.
Syntax:
Texture.new(filename, filtering, options)
Parameters:
- filename: (string) The name of the texture file to be loaded.
- filtering: (boolean, default = false) Whether or not the texture is filtered.
- options: (table, optional) A table that specifies optional paramaters. Currently, "transparentColor", "wrap" and "format" fields are supported.
Examples:
local texture = Texture.new("image.png", false, {transparentColor = 0xff00ff}) -- do not filter and make the color 0xff00ff transparent
local texture = Texture.new("image.png", true, {wrap = Texture.REPEAT}) -- enable filtering and repeat the texture
Back to top
TextureBase
Supported platforms:
Available since version: Gideros 2011.6
Description:
TextureBase is the base class for
Texture and
TexturePack classes. It provides a common functionaly to texture related classes.
- TextureBase.CLAMP = "clamp"
- TextureBase.REPEAT = "repeat"
Back to top
TextureBase:getHeight
Available since version: Gideros 2011.6
Description:
Returns the height of the texture in pixels.
Syntax:
TextureBase:getHeight()
Back to top
TextureBase:getWidth
Available since version: Gideros 2011.6
Description:
Returns the width of the texture in pixels.
Syntax:
TextureBase:getWidth()
Back to top
TextureBase.CLAMP
Available since version: Gideros 2011.6
Description:
Value:
TextureBase.CLAMP = "clamp"
Back to top
TextureBase.REPEAT
Available since version: Gideros 2011.6
Description:
Value:
TextureBase.REPEAT = "repeat"
Back to top
TextureBase.RGB565
Available since version: Gideros 2013.06
Description:
Texture format that can be provided to Texture and TexturePack options table
Value:
TextureBase.RGB565 = "rgb565"
Back to top
TextureBase.RGB888
Available since version: Gideros 2013.06
Description:
Texture format that can be provided to Texture and TexturePack options table
Value:
TextureBase.RGB888 = "rgb888"
Back to top
TextureBase.RGBA4444
Available since version: Gideros 2013.06
Description:
Texture format that can be provided to Texture and TexturePack options table
Value:
TextureBase.RGBA4444 = "rgba4444"
Back to top
TextureBase.RGBA5551
Available since version: Gideros 2013.06
Description:
Texture format that can be provided to Texture and TexturePack options table
Value:
TextureBase.RGBA5551 = "rgba5551"
Back to top
TextureBase.RGBA8888
Available since version: Gideros 2013.06
Description:
Texture format that can be provided to Texture and TexturePack options table
Value:
TextureBase.RGBA8888 = "rgba8888"
Back to top
TexturePack
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
TexturePack class specifies a texture pack (or texture atlas). A texture atlas is a large image which contains many smaller sub-images.
Gideros supports dynamic creation of texture atlases and pre-packed texture atlasses by using "Gideros Texture Packer" tool.
Dynamic Creation of Texture Packs
To create a texture pack dynamically (at run-time), create
TexturePack object with a table of file names of textures.
local pack = TexturePack.new({"1.png", "2.png", "3.png", "4.png")}
Static Creation of Texture Packs
To create a pre-packed texture atlas, use "Gideros Texture Packer" tool:

This tool exports two files: A
.txt
file that specifes the positions of texture regions and a
.png
file of packed texture.
Use these two files to create texture pack:
local pack = TexturePack.new("pack.txt", "pack.png")
Back to top
TexturePack.new
Available since version: Gideros 2011.6
Description:
Creates a new
TexturePack object. This function creates the texture pack at runtime.
Syntax:
TexturePack.new(textures, padding, filtering, options)
Parameters:
- textures: (table) file names of textures.
- padding: (number) the spacing between textures in pixels
- filtering: (boolean, default = false) Whether or not the texture is filtered.
- options: (table, optional) A table that specifies optional paramaters. Currently, "transparentColor" and "format" fields are supported.
Back to top
TexturePack.new
Available since version: Gideros 2011.6
Description:
Creates a new
TexturePack object. This function loads the pre-packed texture atlas created by "Gideros Texture Packer" tool.
Syntax:
TexturePack.new(txtfile, imagefile, filtering, options)
Parameters:
- txtfile: (string)
- imagefile: (string)
- filtering: (boolean, default = false) Whether or not the texture is filtered.
- options: (table, optional) A table that specifies optional paramaters. Currently, "transparentColor" and "format" fields are supported.
Back to top
TexturePack:getTextureRegion
Available since version: Gideros 2011.6
Description:
Returns the texture region of texture pack.
Syntax:
TexturePack:getTextureRegion(texturename)
Parameters:
Examples:
local pack = TexturePack.new({"gfx/1.png", "gfx/2.png", "gfx/3.png", "gfx/4.png"})
local region1 = pack:getTextureRegion("gfx/1.png")
local region2 = pack:getTextureRegion("gfx/2.png")
local region3 = pack:getTextureRegion("gfx/3.png")
local region4 = pack:getTextureRegion("gfx/4.png")
Back to top
TextureRegion
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
TextureRegion class specifies a texture and a rectangular region in it. It is used to define independent texture regions
within a texture atlas which is a large image, which contains many smaller sub-images.
Common uses and examples:
local texture = Texture.new("atlas.png")
-- define 4 equal regions of size 100x100 from "atlas.png"
local region1 = TextureRegion.new(texture, 0, 0, 100, 100)
local region2 = TextureRegion.new(texture, 100, 0, 100, 100)
local region3 = TextureRegion.new(texture, 100, 100, 100, 100)
local region4 = TextureRegion.new(texture, 0, 100, 100, 100)
-- add these regions to scene tree
local bitmap1 = Bitmap.new(region1)
local bitmap2 = Bitmap.new(region2)
local bitmap3 = Bitmap.new(region3)
local bitmap4 = Bitmap.new(region4)
stage:addChild(bitmap1)
stage:addChild(bitmap2)
stage:addChild(bitmap3)
stage:addChild(bitmap4)
Back to top
TextureRegion.new
Available since version: Gideros 2011.6
Description:
Creates a new TextureRegion object.
Syntax:
TextureRegion.new(texture)
Parameters:
- texture: (TextureBase) texture object
Back to top
TextureRegion.new
Available since version: Gideros 2011.6
Description:
Creates a new TextureRegion object.
- If TextureRegion object is created with 1 parameter (texture), it specifies the whole texture.
- If TextureRegion object is created with 5 parameters (texture, x, y, width, height), if specifies a rectangular region within texture.
Syntax:
TextureRegion.new(texture, x, y, width, height)
Parameters:
- texture: (TextureBase) texture object
- x: (number) left coordinate of the region
- y: (number) top coordinate of the region
- width: (number) width of the region
- height: (number) height of the region
Back to top
TextureRegion:getRegion
Available since version: Gideros 2012.08.2
Description:
Returns the coordinates of the region.
Syntax:
TextureRegion:getRegion()
Back to top
TextureRegion:setRegion
Available since version: Gideros 2012.08.2
Description:
Sets the coordinates of the region.
Syntax:
TextureRegion:setRegion(x, y, width, height)
Parameters:
- x: (number) left coordinate of the region
- y: (number) top coordinate of the region
- width: (number) width of the region
- height: (number) height of the region
Back to top
TileMap
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
TileMap class is used to work with tile maps easily and efficiently.
Back to top
TileMap.new
Available since version: Gideros 2011.6
Description:
Syntax:
TileMap.new(width, height, texture, tilewidth, tileheight, spacingx, spacingy, marginx, marginy, displaywidth, displayheight)
Parameters:
- width: (number) The width of the map in tiles
- height: (number) The height of the map in tiles
- texture: (TextureBase) The texture used in rendering tile map
- tilewidth: (number) The width of a tile in pixels
- tileheight: (number) The height of a tile in pixels
- spacingx: (number, default = 0) The x-spacing in pixels between the tiles in this tileset
- spacingy: (number, default = 0) The y-spacing in pixels between the tiles in this tileset
- marginx: (number, default = 0) The x-margin from the top-left of the texture
- marginy: (number, default = 0) The y-margin from the top-left of the texture
- displaywidth: (number, default = tilewidth) The display width of a tile in pixels
- displayheight: (number, default = tileheight) The display height of a tile in pixels
Back to top
TileMap:clearTile
Available since version: Gideros 2011.6
Description:
Set an empty tile at given indices. The tile indices are starting from 1.
Syntax:
TileMap:clearTile(x, y)
Parameters:
- x: (number) The x-position of tile
- y: (number) The y-position of tile
Back to top
TileMap:getTile
Available since version: Gideros 2011.6
Description:
Returns the index of the tile. The tile indices are starting from 1.
Syntax:
TileMap:getTile(x, y)
Parameters:
- x: (number) The x-position of tile
- y: (number) The y-position of tile
Back to top
TileMap:setTile
Available since version: Gideros 2011.6
Description:
Sets the index of the tile. The tile indices are starting from 1.
Syntax:
TileMap:setTile(x, y, tx, ty, flip)
Parameters:
- x: (number) The x-position of tile
- y: (number) The y-position of tile
- tx: (number) The x-index of the tile
- ty: (number) The y-index of the tile
- flip: (number, default = 0) flip flag of tile. Can be combination of TileMap.FLIP_HORIZONTAL, TileMap.FLIP_VERTICAL and TileMap.FLIP_DIAGONAL
Back to top
TileMap:shift
Available since version: Gideros 2011.6
Description:
Shifts the tile map. The arguments are in tiles, not in pixels. By shifting the tile map one by one as needed, you can create dynamic tile maps.
Syntax:
TileMap:shift(dx, dy)
Parameters:
- dx: (number) The x amount of shift in tiles
- dy: (number) The y amount of shift in tiles
Examples:
tilemap:shift(-1, 0) -- shifts the tile map to the left
tilemap:shift(1, 0) -- shifts the tile map to the right
tilemap:shift(0, -1) -- shifts the tile map to the up
tilemap:shift(0, 1) -- shifts the tile map to the down
Back to top
TileMap.FLIP_DIAGONAL
Available since version: Gideros 2011.6
Description:
Value:
TileMap.FLIP_DIAGONAL = 1
Back to top
TileMap.FLIP_HORIZONTAL
Available since version: Gideros 2011.6
Description:
Value:
TileMap.FLIP_HORIZONTAL = 4
Back to top
TileMap.FLIP_VERTICAL
Available since version: Gideros 2011.6
Description:
Value:
TileMap.FLIP_VERTICAL = 2
Back to top
Timer
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
Timer class is used to execute a code at specified intervals. The listener functions are registered
through
Event.TIMER
and
Event.TIMER_COMPLETE
events.
Back to top
Timer.delayedCall
Available since version: Gideros 2011.6
Description:
Provides a simple way to call a function after a set amount of time. This function returns the
Timer object created inside.
Syntax:
Timer.delayedCall(delay, func [, data])
Parameters:
- delay: (number) Delay in miliseconds before the function is called
- func: (function) Function to call
- data: An optional data parameter that is passed as a first argument to the function
Back to top
Timer.new
Available since version: Gideros 2011.6
Description:
Creates a new
Timer object with the specified delay and repeatCount states.
Syntax:
Timer.new(delay, repeatCount)
Parameters:
- delay: The time interval between timer events in milliseconds.
- repeatCount: (default = 0) The number of repetitions. A value of 0 runs the timer infinitely. If nonzero, the timer runs the specified number of times and then stops.
Back to top
Timer.pauseAll
Available since version: Gideros 2011.6
Description:
Pause all timers. Suitable for temporarily pausing all timers when application is paused.
Syntax:
Timer.pauseAll()
Back to top
Timer.resumeAll
Available since version: Gideros 2011.6
Description:
Resume all timers.
Syntax:
Timer.resumeAll()
Back to top
Timer.stopAll
Available since version: Gideros 2011.6
Description:
Stop all timers.
Syntax:
Timer.stopAll()
Back to top
Timer:getCurrentCount
Available since version: Gideros 2011.6
Description:
Returns the current trigger count of the timer. It starts with 0 and if it reaches repeatCount
value, timer stops.
Syntax:
Timer:getCurrentCount()
Back to top
Timer:getDelay
Available since version: Gideros 2011.6
Description:
Returns the time interval between timer events in milliseconds.
Syntax:
Timer:getDelay()
Back to top
Timer:getRepeatCount
Available since version: Gideros 2011.6
Description:
Returns the number of repetitions the timer will make. A value of 0 means the timer runs infinitely. If nonzero, the timer runs the specified number of times and then stops.
Syntax:
Timer:getRepeatCount()
Back to top
Timer:isRunning
Available since version: Gideros 2011.6
Description:
Returns the current running status of timer.
Syntax:
Timer:isRunning()
Back to top
Timer:reset
Available since version: Gideros 2011.6
Description:
Stops the timer and sets the currentCount
property to 0.
Syntax:
Timer:reset()
Back to top
Timer:setDelay
Available since version: Gideros 2011.6
Description:
Sets the time interval between timer events in milliseconds.
Syntax:
Timer:setDelay(delay)
Parameters:
- delay: (number) The time interval between timer events in milliseconds.
Back to top
Timer:setRepeatCount
Available since version: Gideros 2011.6
Description:
Sets the number of repetitions the timer will make. A value of 0 means the timer runs infinitely. If nonzero, the timer runs the specified number of times and then stops.
Syntax:
Timer:setRepeatCount(repeatCount)
Parameters:
- repeatCount: (number) the number of repetitions the timer will make
Back to top
Timer:start
Available since version: Gideros 2011.6
Description:
Starts the timer.
Syntax:
Timer:start()
Back to top
Timer:stop
Available since version: Gideros 2011.6
Description:
Stops the timer. This function doesn't change the currentCount
property.
Syntax:
Timer:stop()
Back to top
Event.TIMER
Available since version: Gideros 2011.6
Description:
This event is dispatched on every
Timer repeat until timer is stopped or the provided amount of repeat count is reached
Value:
Event.TIMER = "timer"
Back to top
Event.TIMER_COMPLETE
Available since version: Gideros 2011.6
Description:
This event is dispatched only when
Timer reached the provided amount of repeat count.
Value:
Event.TIMER_COMPLETE = "timerComplete"
Back to top
TTFont
Supported platforms:
Available since version: Gideros 2011.6
Description:
The
TTFont class is used to load true type fonts.
Back to top
TTFont.new
Available since version: Gideros 2011.6
Description:
Syntax:
TTFont.new(filename, size, text, filtering)
Parameters:
- filename: (string) The name of the TTF file to be loaded
- size: (number) size of the font
- text: (string, optional) if specified, TTFont caches the characters of this test to speed up the rendering
- filtering: (boolean, default = false) Whether or not the font texture is filtered
Back to top
UrlLoader
Supported platforms:
Available since version: Gideros 2012.2.2
Description:
The
UrlLoader class is used to download data from an URL. It can be used to download (and optionally save) text files, XML files, JSON files, image files or binary files, etc.
Downloaded data is delivered at
event.data
field of
Event.COMPLETE
event as string. Lua is eight-bit clean and so strings may contain characters with any numeric value, including embedded zeros. That means that you can store any binary data into a string.
HTTP Request Methods
UrlLoader supports GET, POST, PUT and DELETE methods. These are defined by these string constants:
- **UrlLoader.GET = "get"**
- **UrlLoader.POST = "post"**
- **UrlLoader.PUT = "put"**
- **UrlLoader.DELETE = "delete"**
Common uses and examples:
The example below shows downloading an image file from an URL, saving it to the documents folder and displaying it
on the stage. This example also shows downloading progress and handling errors.
local loader = UrlLoader.new("http://example.com/image.png")
local function onComplete(event)
local out = io.open("|D|image.png", "wb")
out:write(event.data)
out:close()
local b = Bitmap.new(Texture.new("|D|image.png"))
stage:addChild(b)
end
local function onError()
print("error")
end
local function onProgress(event)
print("progress: " .. event.bytesLoaded .. " of " .. event.bytesTotal)
end
loader:addEventListener(Event.COMPLETE, onComplete)
loader:addEventListener(Event.ERROR, onError)
loader:addEventListener(Event.PROGRESS, onProgress)
Back to top
UrlLoader.new
Available since version: Gideros 2012.2.2
Description:
Creates a new
UrlLoader object.
url
parameter specifies the URL to download. This parameter is optional and if specified loading starts immediately.
method
parameter specifies the HTTP request method. It can be one of the values of
UrlLoader.GET
,
UrlLoader.POST
,
UrlLoader.PUT
or
UrlLoader.DELETE
.
The default HTTP method is
UrlLoader.GET
.
body
parameter specifies the HTTP body data. This parameter is used only when the HTTP method is
UrlLoader.POST
or or
UrlLoader.PUT
.
After loading is finished, loaded data is stored at
event.data
field of
Event.COMPLETE
event as string.
Syntax:
UrlLoader.new(url, method, headers, body)
Parameters:
- url: (string, optional) URL to download. This parameter is optional and if specified loading starts immediately.
- method: (string, default = "get") HTTP request method.
- headers: (table, optional) HTTP headers.
- body: (string, optional) HTTP body data. This data is sent as the message body of a request.
Examples:
local url = "http://www.[yourDomain].com/application.php?userid=gideros&login=guest"
local loader1 = UrlLoader.new(url)
local loader2 = UrlLoader.new(url, UrlLoader.GET) -- same as the previous line
local loader3 = UrlLoader.new(url, UrlLoader.POST, "my post data")
local loader4 = UrlLoader.new(url, UrlLoader.PUT, "my put data")
local loader5 = UrlLoader.new(url, UrlLoader.DELETE)
local headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
["User-Agent"] = "Gideros Browser",
}
local loader6 = UrlLoader.new(url, UrlLoader.PUT, headers, "key=value")
Back to top
UrlLoader:close
Available since version: Gideros 2012.2.2
Description:
Terminates the current loading operation.
Syntax:
UrlLoader:close()
Back to top
UrlLoader:load
Available since version: Gideros 2012.2.2
Description:
Loads data from the specified URL. If there is any load operation in progress, it is terminated and new progress starts.
Please refer to [[UrlLoader.new]] for more detailed description of url
, method
and body
parameters.
Syntax:
UrlLoader:load(url, method, headers, body)
Parameters:
- url: (string, optional) URL to download. This parameter is optional and if specified loading starts immediately.
- method: (string, default = "get") HTTP request method.
- headers: (table, optional) HTTP headers.
- body: (string, optional) HTTP body data. This data is sent as the message body of a request.
Back to top
Event.COMPLETE
Available since version: Gideros 2011.6
Description:
This event is dispatched when
UrlLoader has reached the host and loading is complete.
Value:
Event.COMPLETE = "complete"
Event properties:
- data: (string) The downloaded data.
- httpStatusCode: (number) HTTP Response Code from server
Back to top
Event.ERROR
Available since version: Gideros 2011.6
Description:
This event is dispatched when
UrlLoader can't reach the provided host.
Value:
Event.ERROR = "error"
Back to top
Event.PROGRESS
Available since version: Gideros 2011.6
Description:
This event is dispatched to notify of how far the download has progressed.
Value:
Event.PROGRESS = "progress"
Event properties:
- bytesLoaded: (number) The number of bytes loaded.
- bytesTotal: (number) The total number of bytes that will be loaded or -1 if the length can't be determined.
Back to top
UrlLoader.DELETE
Available since version: Gideros 2011.6
Description:
Value:
UrlLoader.DELETE = "delete"
Back to top
UrlLoader.GET
Available since version: Gideros 2011.6
Description:
Value:
UrlLoader.GET = "get"
Back to top
UrlLoader.POST
Available since version: Gideros 2011.6
Description:
Value:
UrlLoader.POST = "post"
Back to top
UrlLoader.PUT
Available since version: Gideros 2011.6
Description:
Value:
UrlLoader.PUT = "put"