Basics
Guides
API Reference
Basics
Guides
API Reference
[22:7] extends: FxObj
Wraps FXGL's PhysicsWorld, the jbox2d-backed physics simulator that drives every collidable entity in the game. Reached at runtime via fxgl.getPhysicsWorld; obtain a wrapper via the (Ajo) constructor. The main user-facing operations are registering CollisionHandlers to react when entities of two types touch, adjusting world gravity, and casting rays for line-of-sight or hit tests. Note: this wrapper is the registration point for CollisionHandler. After constructing a handler via new CollisionHandler(typeA, typeB) and wiring its callbacks, register it here with physicsWorld.addCollisionHandler(handler).
PhysicsWorld (Ajo = null)
Creates a PhysicsWorld wrapper. Empty by default (PhysicsWorld is engine-owned and not user-constructible); the (Ajo) form wraps an existing instance from fxgl.getPhysicsWorld.
Ajo is an optional AussomJavaObject around a PhysicsWorld.addCollisionHandler (object Handler)
Registers a CollisionHandler with the running physics world. The handler fires for every pair of entities matching the type pair the handler was constructed with.
Handler is a CollisionHandler wrapper.this objectremoveCollisionHandler (object Handler)
Removes a previously registered CollisionHandler.
Handler is a CollisionHandler wrapper.this objectclearCollisionHandlers ()
Removes every registered CollisionHandler.
this objectsetGravity (double X, double Y)
Sets the world gravity vector in pixels per second squared. Default in FXGL is (0, 0); a typical 2D platformer uses (0, 600) or similar.
X is the horizontal gravity.Y is the vertical gravity (positive points down on screen).this objectraycast (double Sx, double Sy, double Ex, double Ey)
Casts a ray from (Sx, Sy) to (Ex, Ey) and returns the RaycastResult containing the first hit entity (if any) and the hit point.
Sx is the start X.Sy is the start Y.Ex is the end X.Ey is the end Y.An AussomJavaObject around a RaycastResult.clear ()
Clears all bodies and joints from the world (typically used on level transitions).
this objecttoMeters (double Pixels)
Converts a pixel distance to physics meters.
Pixels is the pixel distance.A double in meters.toPixels (double Meters)
Converts a physics meters distance to pixels.
Meters is the meter distance.A double in pixels.addRevoluteJoint (object E1, object E2, double Ax1, double Ay1, double Ax2, double Ay2)
Creates a hinge (revolute) joint between two entities at the given local anchors. Returns an AussomJavaObject around the RevoluteJoint so callers can set motor / limits / etc.
E1 is the first Entity wrapper.E2 is the second Entity wrapper.Ax1 is the anchor X on E1.Ay1 is the anchor Y on E1.Ax2 is the anchor X on E2.Ay2 is the anchor Y on E2.An AussomJavaObject around the RevoluteJoint.addRopeJoint (object E1, object E2, double Ax1, double Ay1, double Ax2, double Ay2, double Length)
Creates a rope joint between two entities at the given anchors with the supplied rope length.
E1 is the first Entity wrapper.E2 is the second Entity wrapper.Ax1 is the anchor X on E1.Ay1 is the anchor Y on E1.Ax2 is the anchor X on E2.Ay2 is the anchor Y on E2.Length is the maximum rope length.An AussomJavaObject around the RopeJoint.addRopeJointDefault (object E1, object E2)
Creates a default rope joint between two entities (uses their current world positions as anchors).
E1 is the first Entity wrapper.E2 is the second Entity wrapper.An AussomJavaObject around the RopeJoint.addPrismaticJoint (object E1, object E2, double Ax, double Ay, double Limit)
Creates a prismatic (sliding) joint between two entities along the supplied axis with the given travel limit.
E1 is the first Entity wrapper.E2 is the second Entity wrapper.Ax is the axis X.Ay is the axis Y.Limit is the travel limit.An AussomJavaObject around the PrismaticJoint.addJoint (object E1, object E2, object JointDefObj)
Creates a generic joint from a JointDef built directly via AJI (WeldJointDef, MotorJointDef, etc.).
E1 is the first Entity wrapper.E2 is the second Entity wrapper.JointDefObj is an AussomJavaObject around a JointDef.An AussomJavaObject around the created Joint.removeJoint (object JointObj)
Removes a previously created joint.
JointObj is an AussomJavaObject around the Joint.this objectgetJBox2DWorld ()
Returns the underlying jbox2d World as an AussomJavaObject. Use for advanced operations (iterating bodies, custom contact filters) not surfaced by the wrapper.
An AussomJavaObject around the jbox2d World.toMeterPoint (double X, double Y)
Converts a JavaFX Point2D (pixels) to a jbox2d Vec2 (meters).
X is the pixel X.Y is the pixel Y.An AussomJavaObject around a Vec2.toPixelPoint (object VecObj)
Converts a jbox2d Vec2 (meters) to a JavaFX Point2D (pixels).
VecObj is an AussomJavaObject (or Vec2 wrapper) around a Vec2.An AussomJavaObject around a Point2D.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.