public class PhysicsJoint

  1. Object
  2. PhysicsJoint
A constraint that ties two PhysicsBody objects together (or a body to the world) – a pin, a slider, a weld, a spring, a drag handle. Create one through the PhysicsWorld#createRevoluteJoint(PhysicsBody, PhysicsBody, float, float) family of methods; they take anchor points in pixels and handle the meters/y-flip conversion for you. For joint-type-specific tuning (motors, limits, spring frequency) reach the underlying engine joint with #getNativeJoint().

Methods

public PhysicsBody getBodyA()The first body the joint connects.
public PhysicsBody getBodyB()The second body the joint connects.
public boolean isActive()True while the joint is still part of the world (i.e. not yet destroyed).
public void setTarget(float xPx, float yPx)Moves a mouse joint’s target to the given pixel point (e.g. the current touch position).
public void destroy()Removes the joint from its world.
public Joint getNativeJoint()The underlying Box2D joint, for type-specific control (cast it to com.codename1.gaming.physics.box2d.dynamics.joints.RevoluteJoint etc. to set motors and limits).

Inherited methods

Method details

getBodyA

public PhysicsBody getBodyA()
The first body the joint connects.

getBodyB

public PhysicsBody getBodyB()
The second body the joint connects.

isActive

public boolean isActive()
True while the joint is still part of the world (i.e. not yet destroyed).

setTarget

public void setTarget(float xPx, float yPx)
Moves a mouse joint’s target to the given pixel point (e.g. the current touch position). No effect on other joint types.

destroy

public void destroy()
Removes the joint from its world. Using the joint afterwards is undefined.

getNativeJoint

public Joint getNativeJoint()
The underlying Box2D joint, for type-specific control (cast it to com.codename1.gaming.physics.box2d.dynamics.joints.RevoluteJoint etc. to set motors and limits). Anchors and the y-axis on the native joint are in meters, y up.