object.isSleepingAllowed

Type Boolean
Object Body
Library physics.*
Revision 2017.3060
Keywords body, isSleepingAllowed
See also object.isAwake

Overview

A boolean for whether a body is allowed to "sleep." The default is true.

Gotchas

Keeping bodies awake has a larger computational overhead and it's usually not required because collisions with other bodies will automatically wake them up. However, forcing the "awake" state is useful in cases such as tilt-gravity since sleeping bodies do not respond to changes in global gravity.

Example

-- Create a rectangle
local myRect = display.newRect( 0, 0, 100, 100 )

-- Add a body to the rectangle
physics.addBody( myRect, "dynamic" )

-- Prevent the rectangle's ability to "sleep"
myRect.isSleepingAllowed = false