Type Boolean Object Body Library physics.* Revision Release 2024.3703 Keywords body, isFixedRotation
A boolean for whether the rotation of the body should be locked, even if the body is under load or subjected to false
.
It's critical that you set this body property after the object is already made into a physical object via physics.addBody(). If you apply this property before the physics.addBody() command for the object, it will merely be treated as a property of the object like any other custom property and, in that case, it will not cause any physical change in terms of locking rotation.
-- Create a rectangle local myRect = display.newRect( 0, 0, 20, 100 ) -- Add a body to the rectangle physics.addBody( myRect, "dynamic" ) myRect.isFixedRotation = true