Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: World

[20:7] extends: FxObj

Wraps jbox2d's World (com.almasb.fxgl.physics.box2d.dynamics.World), the underlying physics simulation. FXGL wires a single World per game via PhysicsWorld.getJBox2DWorld(), which the engine already steps for you — direct World use is an escape hatch for advanced setups (custom joints, manual stepping, custom contact listeners / filters, low-level body management).

Methods

  • World (object GravityVec = null)

    Creates a new standalone World with the given gravity. In normal play you do not call this — use the engine-managed World via PhysicsWorld.getJBox2DWorld().

    • @p GravityVec is a Vec2 wrapper.
  • adopt (object Ajo)

    Wraps an existing World AussomJavaObject.

  • createBody (object BodyDefObj)

    Creates a Body from a BodyDef wrapper.

  • destroyBody (object BodyObj)

    Destroys a Body wrapped by the given wrapper.

  • createJoint (object JointDefAjo)

    Creates a joint from a JointDef AJO.

  • destroyJoint (object JointAjo)

    Destroys a joint.

  • step (double Dt, int VelocityIterations, int PositionIterations)

    Steps the simulation by Dt seconds.

    • @p Dt is the time delta in seconds.
    • @p VelocityIterations is the velocity solver iteration count.
    • @p PositionIterations is the position solver iteration count.
  • clearForces ()

    Zeroes accumulated forces on every body.

  • getGravity ()

    Returns the gravity Vec2 wrapper.

  • setGravity (object GravityVec)

  • getBodyCount ()

  • getJointCount ()

  • getContactCount ()

  • isSleepingAllowed ()

  • setSleepingAllowed (bool V)

  • isContinuousPhysics ()

  • setContinuousPhysics (bool V)

  • isWarmStarting ()

  • setWarmStarting (bool V)

  • isLocked ()

  • isAutoClearForces ()

  • setAutoClearForces (bool V)

  • getContactList ()

    Returns the contact list head AJO.

  • getBodies ()

    Returns the bodies as an Array AJO.

  • setContactListener (object ListenerAjo)

    Installs a ContactListener. Pass either a raw AJO or use aji.closure(...) to bridge an Aussom callback set.

  • setContactFilter (object FilterAjo)

    Installs a ContactFilter.

  • isAllowSleep ()

    Returns the World's "allow sleep" flag (distinct from the per-body sleepingAllowed flag). When true, bodies with low energy may be put to sleep by the solver.

  • setAllowSleep (bool V)

    Sets the World's allow-sleep flag.

  • isSubStepping ()

    Returns true when sub-stepping integration is enabled.

  • setSubStepping (bool V)

    Enables / disables sub-stepping integration.

  • getDestructionListener ()

    Returns the installed DestructionListener AJO (or null when unset). Used to receive callbacks when fixtures / joints are destroyed by the simulation.

  • setDestructionListener (object ListenerAjo)

    Installs a DestructionListener. Pass either a wrapper carrying an .obj or the raw AJO produced by aji.closure.

  • queryAABB (object CallbackAjo, object AABBAjo)

    Issues an AABB query against the world. Pass a QueryCallback AJO (typically built via aji.closure) and an AABB AJO; the callback fires for every fixture whose bbox overlaps the AABB.

  • raycast (object CallbackAjo, object Point1Vec, object Point2Vec)

    Issues a raycast from Point1 to Point2. The RayCastCallback AJO is invoked once per fixture intersection.

  • getPool ()

    Returns the internal object pool (IWorldPool) AJO. Escape hatch.

  • getParticleSystem ()

    Returns the underlying ParticleSystem AJO (Box2D particle physics). Use through the returned AJO directly — the ParticleSystem itself is internal and not wrapped.

  • getParticleCount ()

    Returns the current number of active particles.

  • computeParticleCollisionEnergy ()

    Returns the total collision energy of all active particles.