Difference between revisions of "B2.DistanceJoint"
From GiderosMobile
Line 2: | Line 2: | ||
<languages /> | <languages /> | ||
<!-- GIDEROSOBJ:b2.DistanceJoint --> | <!-- GIDEROSOBJ:b2.DistanceJoint --> | ||
− | ''' | + | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> |
− | ''' | + | '''Available since:''' Gideros 2011.6<br/> |
− | ''' | + | '''Inherits from:''' [[Special:MyLanguage/b2.Joint|b2.Joint]]<br/> |
− | === | + | |
− | + | === 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. | + | 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''' | + | '''Distance joint''' |
− | <source lang="lua">local jointDef = b2.createDistanceJointDef(body1, body2, 100, 100, 200, 100) | + | <source lang="lua"> |
+ | local jointDef = b2.createDistanceJointDef(body1, body2, 100, 100, 200, 100) | ||
local distanceJoint = world:createJoint(jointDef) | local distanceJoint = world:createJoint(jointDef) | ||
− | --by default length between two bodies is the length they have between them when joint was created | + | --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:setLength(200) | ||
distanceJoint:setDampingRatio(0.5) | distanceJoint:setDampingRatio(0.5) | ||
− | distanceJoint:setFrequency(4)</source> | + | distanceJoint:setFrequency(4) |
+ | </source> | ||
+ | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
− | === | + | === Methods === |
− | [[Special:MyLanguage/b2.DistanceJoint:getDampingRatio|b2.DistanceJoint:getDampingRatio]] '' | + | [[Special:MyLanguage/b2.DistanceJoint:getDampingRatio|b2.DistanceJoint:getDampingRatio]] ''returns the damping ratio''<br/><!-- GIDEROSMTD:b2.DistanceJoint:getDampingRatio() returns the damping ratio --> |
− | [[Special:MyLanguage/b2.DistanceJoint:getFrequency|b2.DistanceJoint:getFrequency]] '' | + | [[Special:MyLanguage/b2.DistanceJoint:getFrequency|b2.DistanceJoint:getFrequency]] ''returns the mass-spring-damper frequency in Hertz''<br/><!-- GIDEROSMTD:b2.DistanceJoint:getFrequency() returns the mass-spring-damper frequency in Hertz --> |
− | [[Special:MyLanguage/b2.DistanceJoint:getLength|b2.DistanceJoint:getLength]] '' | + | [[Special:MyLanguage/b2.DistanceJoint:getLength|b2.DistanceJoint:getLength]] ''returns the length of this distance joint in meters''<br/><!-- GIDEROSMTD:b2.DistanceJoint:getLength() returns the length of this distance joint in meters --> |
− | [[Special:MyLanguage/b2.DistanceJoint:setDampingRatio|b2.DistanceJoint:setDampingRatio]] '' | + | [[Special:MyLanguage/b2.DistanceJoint:setDampingRatio|b2.DistanceJoint:setDampingRatio]] ''sets the damping ratio (0 = no damping, 1 = critical damping)''<br/><!-- GIDEROSMTD:b2.DistanceJoint:setDampingRatio(ratio) sets the damping ratio (0 = no damping, 1 = critical damping) --> |
− | [[Special:MyLanguage/b2.DistanceJoint:setFrequency|b2.DistanceJoint:setFrequency]] '' | + | [[Special:MyLanguage/b2.DistanceJoint:setFrequency|b2.DistanceJoint:setFrequency]] ''sets the mass-spring-damper frequency in Hertz''<br/><!-- GIDEROSMTD:b2.DistanceJoint:setFrequency(frequency) sets the mass-spring-damper frequency in Hertz --> |
− | [[Special:MyLanguage/b2.DistanceJoint:setLength|b2.DistanceJoint:setLength]] '' | + | [[Special:MyLanguage/b2.DistanceJoint:setLength|b2.DistanceJoint:setLength]] ''sets the natural joint length in meters''<br/><!-- GIDEROSMTD:b2.DistanceJoint:setLength(length) sets the natural joint length in meters --> |
+ | |||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
− | === | + | === Events === |
− | === | + | === Constants === |
|} | |} | ||
− | + | ---- | |
+ | *'''[[LiquidFun]]''' |
Revision as of 08:26, 17 February 2020
Supported platforms:
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
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)
Methodsb2.DistanceJoint:getDampingRatio returns the damping ratio |
EventsConstants |