A World is an Object representing the state of a Physics simulation and it configurations.

Constructor

new(options:WorldOptions)

Variables

@:value(0)accumulatedTime:Float = 0

read onlycount:Int

read onlygravity:Vector2

The amount of acceleration applied to each Body member every Step.

height:Float

Height of the World, extending down from the World's Y position.

history:Null<History_Array_echo_data_BodyState>

iterations:Int

The amount of iterations that occur each time the World is stepped. The higher the number, the more stable the Physics Simulation will be, at the cost of performance.

quadtree:QuadTree

The World's QuadTree for dynamic Bodies. Generally doesn't need to be touched.

static_quadtree:QuadTree

The World's QuadTree for static Bodies. Generally doesn't need to be touched.

width:Float

Width of the World, extending right from the World's X position.

x:Float

The World's position on the X axis.

y:Float

The World's position on the Y axis.

Methods

add(body:Body):Body

inlinecenter(?rect:Rect):Rect

clear():Void

Clears the World's members and listeners.

dispose():Void

Disposes the World. DO NOT use the World after disposing it, as it could lead to null reference errors.

inlinedynamics():Array<Body>

Returns a new Array containing every dynamic Body in the World.

@:value({ recursive : true })inlinefor_each(f:Body ‑> Void, recursive:Bool = true):Void

Runs a function on every Body in the World

Parameters:

f

Function to perform on each Body.

recursive

Currently not supported.

@:value({ recursive : true })inlinefor_each_dynamic(f:Body ‑> Void, recursive:Bool = true):Void

Runs a function on every dynamic Body in the World

Parameters:

f

Function to perform on each dynamic Body.

recursive

Currently not supported.

@:value({ recursive : true })inlinefor_each_static(f:Body ‑> Void, recursive:Bool = true):Void

Runs a function on every static Body in the World

Parameters:

f

Function to perform on each static Body.

recursive

Currently not supported.

reset_quadtrees():Void

Resets the World's dynamic and static Quadtrees.

inlineset(x:Float, y:Float, width:Float, height:Float):Void

Sets the size of the World. Only Bodies within the world bound will be collided

Parameters:

x

The x position of the world bounds

y

The y position of the world bounds

width

The width of the world bounds

height

The height of the world bounds

set_from_members():Void

Sets the size of the World based just large enough to encompass all the members.

inlineset_from_shape(s:Shape):Void

Sets the size of the World based on a given shape.

Parameters:

s

The shape to use as the boundaries of the World

inlinestatics():Array<Body>

Returns a new Array containing every static Body in the World.