Class PhysicsJoint
java.lang.Object
com.codename1.gaming.physics.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().-
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Removes the joint from its world.getBodyA()The first body the joint connects.getBodyB()The second body the joint connects.The underlying Box2D joint, for type-specific control (cast it tocom.codename1.gaming.physics.box2d.dynamics.joints.RevoluteJointetc. to set motors and limits).booleanisActive()True while the joint is still part of the world (i.e. not yet destroyed).voidsetTarget(float xPx, float yPx) Moves a mouse joint's target to the given pixel point (e.g. the current touch position).
-
Method Details
-
getBodyA
The first body the joint connects. -
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
The underlying Box2D joint, for type-specific control (cast it tocom.codename1.gaming.physics.box2d.dynamics.joints.RevoluteJointetc. to set motors and limits). Anchors and the y-axis on the native joint are in meters, y up.
-