×
A new build of Corona SDK is now available to subscribers. Not a subscriber? Subscribe now.
CoronaSDK 2014.2379 | Released: 24 Jul 2014, 5:28pm | What's New | Download Now

physics.newJoint( )

Description:

Joints are used to assemble more complex game objects from multiple rigid bodes. To construct a joint, first construct the bodies that will be joined, and then call this method with the desired joint constructor type.

To remove a joint, use joint:removeSelf( )

NOTE: This API reference page is incomplete. See the Physics Joint Guide to see how to deal with the various joints.

Syntax:

physics.newJoint( jointType, object1, object2, anchorX, anchorY )

Example:

myJoint = physics.newJoint( "pivot", crateA, crateB, 200,300 )

Parameters:

jointType
string: One of the following joint types:

  • pivot
  • distance
  • piston
  • friction
  • weld
  • wheel
  • pulley
  • touch

object1
First object used in joint.

object2
Second object used in joint.

anchorX
Defines the X-location of the joint anchor point.

anchorY
Defines the Y-location of the joint anchor point.

Returns:

Joint object

Starting with build 2011.598, returns joint object if the API succeeded or nil if it failed. (The API will fail if called in any Collision Event handler.)

Remarks:

Note: This API should not be used in a Collision Event handler.

Starting with build 2011.598, this API returns nil and display a warning message in the simulator if the API cannot be processed. Before build 2011.598, calling the API may crash the simulator and the app when running on the device.

Supported on operating systems and platforms for build numbers shown:
  • Mac OS X:
    Build 2010.222
  • Windows:
    Build 2010.222
  • iOS:
    Build 2010.222
  • Android:
    Build 2010.222