object:applyTorque()

Type Function
Object Body
Library physics.*
Return value none
Revision Release 2024.3703
Keywords body, applyTorque
See also object:applyAngularImpulse()
object:applyForce()
object:applyLinearImpulse()

Overview

A function that accepts a numerical value for applied rotational force. The body will rotate about its center of mass.

Syntax

object:applyTorque( appliedForce )
appliedForce (required)

Number. Amount of force to be applied.

Example

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

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

myRect:applyTorque( 100 )