Type Number Object Body Library physics.* Revision 2017.3060 Keywords body, gravityScale See also physics.setGravity()
Use the gravityScale
property to adjust the gravity on a single body. For example, setting it to 0
makes the body float (no gravity). The default value is 1.0
which means the body will behave under the normal simulated gravity.
This can be a negative value which will effectively reverse the object's normal gravity.
Increased gravity can decrease physics stability, so you should set this property conservatively.
-- Create a rectangle local myRect = display.newRect( 0, 0, 100, 100 ) -- Add a body to the rectangle physics.addBody( myRect, "dynamic" ) -- Set gravity scale myRect.gravityScale = 0.25