×
A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now.
CoronaSDK 2014.2407 | Released: 21 Aug 2014, 1:22pm | What's New | Download Now

physics.start()

Description:

This function start the physics simulation and should be called before any other physics functions.

By default, Box2D bodies not involved in a collision will "sleep" after a couple of seconds. This reduces overhead, but in some cases you may not want this behavior. For example, the "ShapeTumbler" sample code will not work well if bodies are allowed to sleep, since sleeping bodies do not respond to changes in the direction of gravity.

You can override this behavior on a given body with body.isSleepingAllowed = false, but you can also override this globally for all bodies in the world by using an optional boolean parameter in start:

Syntax:

physics.start( noSleep )

Example:

physics.start( true ) -- starts the Physics engine and prevents all bodies from sleeping

Parameters:

boolean
true prevent all bodies from sleeping.
false allows all bodies to sleep (default mode).

Returns:

Nothing.

Remarks:

Note:
require( "physics" ) and physics.start() must be at the top of the main.lua file.

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