Difference between revisions of "B2.PulleyJoint"
m (Text replacement - "</source" to "</syntaxhighlight") |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 11: | Line 11: | ||
=== <translate>Examples</translate> === | === <translate>Examples</translate> === | ||
'''Pulley joint''' | '''Pulley joint''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
--create empty box2d body for joint | --create empty box2d body for joint | ||
local ground = world:createBody({}) | local ground = world:createBody({}) | ||
Line 22: | Line 22: | ||
1) -- ratio (if < 1 -> makes body 2 heavier, > 1 makes body 1 heavier, =1 makes them equal | 1) -- ratio (if < 1 -> makes body 2 heavier, > 1 makes body 1 heavier, =1 makes them equal | ||
local pulleyJoint = world:createJoint(jointDef) | local pulleyJoint = world:createJoint(jointDef) | ||
− | </ | + | </syntaxhighlight> |
{|- | {|- | ||
Line 39: | Line 39: | ||
---- | ---- | ||
+ | *'''[[B2.Joint]]''' | ||
*'''[[LiquidFun]]''' | *'''[[LiquidFun]]''' |
Latest revision as of 16:55, 12 July 2023
Supported platforms:
Available since: Gideros 2011.6
Inherits from: b2.Joint
Description
The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1 ratio * length2 <= constant Yes, the force transmitted is scaled by the ratio. The pulley also enforces a maximum length limit on both sides. This is useful to prevent one side of the pulley hitting the top.
Examples
Pulley joint
--create empty box2d body for joint
local ground = world:createBody({})
local jointDef = b2.createPulleyJointDef(body1, body2,
200, 100, --coordinates where "imaginary string" is attached in the air for body 1
350, 100, --coordinates where "imaginary string" is attached in the air for body 2
200, 300, --coordinates where "imaginary string" is attached to the body 1
350, 300, --coordinates where "imaginary string" is attached in the body 2
1) -- ratio (if < 1 -> makes body 2 heavier, > 1 makes body 1 heavier, =1 makes them equal
local pulleyJoint = world:createJoint(jointDef)
Methodsb2.PulleyJoint:getGroundAnchorA returns the x and y coordinates of the first ground anchor |
EventsConstants |