object.bodyType

Type String
Object Body
Library physics.*
Revision Release 2024.3703
Keywords body, bodyType, dynamic, static, kinematic
See also physics.addBody()

Overview

A string value for the type of physical body being simulated. Possible values include:

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.

Example

-- Create a rectangle
local myRect = display.newRect( 0, 0, 100, 100 )
 
-- Add a body to the rectangle
physics.addBody( myRect, { isSensor = false } )
 
-- Set the body's type to kinematic
myRect.bodyType = "kinematic"