×
A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now.
CoronaSDK 2014.2279 | Released: 23 Apr 2014, 3:40pm | What's New | Download Now

physics.setGravity()

Description:

Sets the x,y components of the global gravity vector, in units of m/s2. The default is ( 0, 9.8 ) to simulate standard Earth gravity, pointing downwards on the y-axis.

Syntax:

physics.setGravity( gx, gy )

Example:

local function onTilt( event )
        physics.setGravity( 10 * event.xGravity, -10 * event.yGravity )
end
 
Runtime:addEventListener( "accelerometer", onTilt )

Parameters:

gx
Sets the global gravity vector in X direction, in units of m/s2.

gy
Sets the global gravity vector in Y direction, in units of m/s2.

Returns:

Nothing.

Remarks:
Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Corona SDK 2.0
  • Windows:
    Corona SDK 2.0
  • iOS:
    Corona SDK 2.0
  • Android:
    Corona SDK 2.0