Difference between revisions of "love.physics.newDistanceJoint"

m
(Added warning to not call during callbacks)
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Create a distance joint between two bodies.
+
Creates a [[DistanceJoint]] between two bodies.
  
 
This joint constrains the distance between two points on two bodies to be constant. These two points are specified in world coordinates and the two bodies are assumed to be in place when this joint is created. The first anchor point is connected to the first body and the second to the second body, and the points define the length of the distance joint.
 
This joint constrains the distance between two points on two bodies to be constant. These two points are specified in world coordinates and the two bodies are assumed to be in place when this joint is created. The first anchor point is connected to the first body and the second to the second body, and the points define the length of the distance joint.
 +
 +
[[File:physicsJointDistance.PNG]]
 +
 +
{{notice|Making changes to a [[World]] is not allowed inside of the [[beginContact]], [[endContact]], [[preSolve]], and [[postSolve]] callback functions, as BOX2D locks the world during these callbacks.}}
 +
 
== Function ==
 
== Function ==
 +
{{newin|[[0.8.0]]|080|type=variant}}
 +
=== Synopsis ===
 +
<source lang="lua">
 +
joint = love.physics.newDistanceJoint( body1, body2, x1, y1, x2, y2, collideConnected )
 +
</source>
 +
=== Arguments ===
 +
{{param|Body|body1|The first body to attach to the joint.}}
 +
{{param|Body|body2|The second body to attach to the joint.}}
 +
{{param|number|x1|The x position of the first anchor point (world space).}}
 +
{{param|number|y1|The y position of the first anchor point (world space).}}
 +
{{param|number|x2|The x position of the second anchor point (world space).}}
 +
{{param|number|y2|The y position of the second anchor point (world space).}}
 +
{{param|boolean|collideConnected (false)|Specifies whether the two bodies should collide with each other.}}
 +
=== Returns ===
 +
{{param|DistanceJoint|joint|The new distance joint.}}
 +
 +
== Function ==
 +
{{oldin|[[0.8.0]]|080|type=variant}}
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
Line 10: Line 33:
 
{{param|Body|body1|The first body to attach to the joint.}}
 
{{param|Body|body1|The first body to attach to the joint.}}
 
{{param|Body|body2|The second body to attach to the joint.}}
 
{{param|Body|body2|The second body to attach to the joint.}}
{{param|number|x1|The x position of the first anchor point.}}
+
{{param|number|x1|The x position of the first anchor point (world space).}}
{{param|number|y1|The y position of the first anchor point.}}
+
{{param|number|y1|The y position of the first anchor point (world space).}}
{{param|number|x2|The x position of the second anchor point.}}
+
{{param|number|x2|The x position of the second anchor point (world space).}}
{{param|number|y2|The y position of the second anchor point.}}
+
{{param|number|y2|The y position of the second anchor point (world space).}}
 
 
 
=== Returns ===
 
=== Returns ===
{{param|Joint|joint|The new distance joint.}}
+
{{param|DistanceJoint|joint|The new distance joint.}}
 
== See Also ==
 
== See Also ==
 
* [[parent::love.physics]]
 
* [[parent::love.physics]]
* [[DistanceJoint]]
+
* [[Constructs::DistanceJoint]]
 +
* [[Constructs::Joint]]
 
[[Category:Functions]]
 
[[Category:Functions]]
{{#set:Description=Create a distance joint between two bodies.
+
{{#set:Description=Creates a [[DistanceJoint]] between two bodies.}}
}}
+
{{#set:Since=000}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.physics.newDistanceJoint}}
 
{{i18n|love.physics.newDistanceJoint}}

Latest revision as of 07:50, 14 October 2018

Creates a DistanceJoint between two bodies.

This joint constrains the distance between two points on two bodies to be constant. These two points are specified in world coordinates and the two bodies are assumed to be in place when this joint is created. The first anchor point is connected to the first body and the second to the second body, and the points define the length of the distance joint.

physicsJointDistance.PNG

O.png Making changes to a World is not allowed inside of the beginContact, endContact, preSolve, and postSolve callback functions, as BOX2D locks the world during these callbacks.  


Function

Available since LÖVE 0.8.0
This variant is not supported in earlier versions.

Synopsis

joint = love.physics.newDistanceJoint( body1, body2, x1, y1, x2, y2, collideConnected )

Arguments

Body body1
The first body to attach to the joint.
Body body2
The second body to attach to the joint.
number x1
The x position of the first anchor point (world space).
number y1
The y position of the first anchor point (world space).
number x2
The x position of the second anchor point (world space).
number y2
The y position of the second anchor point (world space).
boolean collideConnected (false)
Specifies whether the two bodies should collide with each other.

Returns

DistanceJoint joint
The new distance joint.

Function

Removed in LÖVE 0.8.0
This variant is not supported in that and later versions.

Synopsis

joint = love.physics.newDistanceJoint( body1, body2, x1, y1, x2, y2 )

Arguments

Body body1
The first body to attach to the joint.
Body body2
The second body to attach to the joint.
number x1
The x position of the first anchor point (world space).
number y1
The y position of the first anchor point (world space).
number x2
The x position of the second anchor point (world space).
number y2
The y position of the second anchor point (world space).

Returns

DistanceJoint joint
The new distance joint.

See Also


Other Languages