physics.removeBody()

Type Function
Library physics.*
Return value Boolean
Revision Current Public Release (2017.3068)
Keywords physics, bodies, physics body
See also physics.addBody()

Overview

Removes a physics body from a display object without destroying the entire object. This removes the body created with physics.addBody().

This API only removes the physics body from the DisplayObject — it does not remove the display object itself.

This function returns true if the body was removed and false if the call failed. The API will fail if called in any collision event listener.

Gotchas

This call cannot be used in a collision event. However, your collision handler may set a flag or include a time delay via timer.performWithDelay() so that the action can occur in the next application cycle or later. See the Collision Detection guide for a complete list of which APIs and methods are subject to this rule.

Syntax

physics.removeBody( object )
object (required)

DisplayObject. The object whose physics body should be removed.

Example

if not ( physics.removeBody( object ) ) then

    print( "Could not remove physics body" )

end