Class PhysicsJoint

java.lang.Object
com.codename1.gaming.physics.PhysicsJoint

public class PhysicsJoint extends Object
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().
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes the joint from its world.
    The first body the joint connects.
    The second body the joint connects.
    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).
    boolean
    True while the joint is still part of the world (i.e. not yet destroyed).
    void
    setTarget(float xPx, float yPx)
    Moves a mouse joint's target to the given pixel point (e.g. the current touch position).

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.