object.isFixedRotation

Type Boolean
Object Body
Library physics.*
Revision 2017.3178
Keywords body, isFixedRotation

Overview

A boolean for whether the rotation of the body should be locked, even if the body is under load or subjected to off-center forces. The default is 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.

Example

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

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

myRect.isFixedRotation = true