Difference between revisions of "B2.DistanceJoint"

From GiderosMobile
m (Text replacement - "</source" to "</syntaxhighlight")
Line 18: Line 18:
 
distanceJoint:setDampingRatio(0.5)
 
distanceJoint:setDampingRatio(0.5)
 
distanceJoint:setFrequency(4)
 
distanceJoint:setFrequency(4)
</source>
+
</syntaxhighlight>
  
 
{|-
 
{|-

Revision as of 16:54, 12 July 2023


Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2011.6
Inherits from: b2.Joint

Description

A distance joint constrains two points on two bodies to remain at a fixed distance from each other. You can view this as a massless, rigid rod.

Examples

Distance joint <source lang="lua"> local jointDef = b2.createDistanceJointDef(body1, body2, 100, 100, 200, 100) local distanceJoint = world:createJoint(jointDef) --by default length between two bodies is the length they have between them when joint was created but it is possilbe to change it using distanceJoint:setLength(200) distanceJoint:setDampingRatio(0.5) distanceJoint:setFrequency(4) </syntaxhighlight>

Methods

b2.DistanceJoint:getDampingRatio returns the damping ratio
b2.DistanceJoint:getFrequency returns the mass-spring-damper frequency in Hertz
b2.DistanceJoint:getLength returns the length of this distance joint in meters
b2.DistanceJoint:setDampingRatio sets the damping ratio (0 = no damping, 1 = critical damping)
b2.DistanceJoint:setFrequency sets the mass-spring-damper frequency in Hertz
b2.DistanceJoint:setLength sets the natural joint length in meters

Events

Constants