Difference between revisions of "B2.DistanceJoint"
From GiderosMobile
Line 6: | Line 6: | ||
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. <br /> | 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. <br /> | ||
<br /> | <br /> | ||
+ | === Examples === | ||
+ | '''Distance joint'''<br/> | ||
+ | <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)</source> | ||
{|- | {|- | ||
| style="width: 50%;"| | | style="width: 50%;"| |
Revision as of 10:40, 23 August 2018
Supported platforms: android, ios, mac, pc
Available since: Gideros 2011.6
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 |