Difference between revisions of "B2.PulleyJoint"

From GiderosMobile
Line 2: Line 2:
 
'''Supported platforms:''' android, ios, mac, pc<br/>
 
'''Supported platforms:''' android, ios, mac, pc<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
=== Description ===
+
=== <translate>Description</translate> ===
 
<translate><br />
 
<translate><br />
 
The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1  ratio * length2 &lt;= 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. <br />
 
The pulley joint is connected to two bodies and two fixed ground points. The pulley supports a ratio such that: length1  ratio * length2 &lt;= 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. <br />
 
<br /></translate>
 
<br /></translate>
=== Examples ===
+
=== <translate>Examples</translate> ===
 
'''Pulley joint'''<br/>
 
'''Pulley joint'''<br/>
 
<source lang="lua">--create empty box2d body for joint
 
<source lang="lua">--create empty box2d body for joint
Line 20: Line 20:
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== Methods ===
+
=== <translate>Methods</translate> ===
 
[[Special:MyLanguage/b2.PulleyJoint:getGroundAnchorA|b2.PulleyJoint:getGroundAnchorA]] ''<translate>returns the x and y coordinates of the first ground anchor</translate>''<br/>
 
[[Special:MyLanguage/b2.PulleyJoint:getGroundAnchorA|b2.PulleyJoint:getGroundAnchorA]] ''<translate>returns the x and y coordinates of the first ground anchor</translate>''<br/>
 
[[Special:MyLanguage/b2.PulleyJoint:getGroundAnchorB|b2.PulleyJoint:getGroundAnchorB]] ''<translate>returns the x and y coordinates of the second ground anchor</translate>''<br/>
 
[[Special:MyLanguage/b2.PulleyJoint:getGroundAnchorB|b2.PulleyJoint:getGroundAnchorB]] ''<translate>returns the x and y coordinates of the second ground anchor</translate>''<br/>
Line 27: Line 27:
 
[[Special:MyLanguage/b2.PulleyJoint:getRatio|b2.PulleyJoint:getRatio]] ''<translate>returns the joint ratio</translate>''<br/>
 
[[Special:MyLanguage/b2.PulleyJoint:getRatio|b2.PulleyJoint:getRatio]] ''<translate>returns the joint ratio</translate>''<br/>
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== Events ===
+
=== <translate>Events</translate> ===
=== Constants ===
+
=== <translate>Constants</translate> ===
 
|}
 
|}

Revision as of 07:28, 24 August 2018

Supported platforms: android, ios, mac, pc
Available since: Gideros 2011.6

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)

Methods

b2.PulleyJoint:getGroundAnchorA returns the x and y coordinates of the first ground anchor
b2.PulleyJoint:getGroundAnchorB returns the x and y coordinates of the second ground anchor
b2.PulleyJoint:getLengthA returns the current length of the segment attached to bodyA
b2.PulleyJoint:getLengthB returns the current length of the segment attached to bodyB
b2.PulleyJoint:getRatio returns the joint ratio

Events

Constants