World

class World extends Container

an object representing the physic world, and responsible for managing and updating all childs and physics

Constructor


new World(x: number, y: number, width: number, height: number) → {}
Parameters:
Name Type Attributes Default Description
x number

<optional>

0

position of the container (accessible via the inherited pos.x property)

y number

<optional>

0

position of the container (accessible via the inherited pos.y property)

width number

<optional>

game.viewport.width

width of the container

height number

<optional>

game.viewport.height

height of the container

Summary


Properties inherited from Rect

number
bottom
number
centerX
number
centerY
number
height
number
left
number
right
number
top
number
width

Properties inherited from Polygon

Array<Vector2d>
points

Public Properties


app world.js:31
app: Application = undefined

the application (game) this physic world belong to

bodies world.js:74
bodies: Set<Body>

the active physic bodies in this simulation

broadphase world.js:83
broadphase: QuadTree

the instance of the game world quadtree used for broadphase

fps world.js:38
fps: Vector2d = 60

the rate at which the game world is updated, may be greater than or lower than the display fps

See: timer.maxfps
gravity world.js:50
gravity: Vector2d = <0,0.98>

world gravity

preRender world.js:60
preRender: boolean = false

Specify the rendering method for tile layers.
if false visible part of the layers are rendered dynamically,
if true the entire layers are first rendered into an offscreen canvas.
the "best" rendering method depends of your game (amount of layer, layer size, amount of tiles per layer, etc.)
note : rendering method is also configurable per layer by adding this property to your layer (in Tiled).

Public Methods


addBody world.js:122
addBody(body: Body) → {World}

Add a physic body to the game world

Parameters:
Name Type Description
body Body
Returns:
Type Description
World

this game world

See: Container.addChild
removeBody world.js:136
removeBody(body: Body) → {World}

Remove a physic body from the game world

Parameters:
Name Type Description
body Body
Returns:
Type Description
World

this game world

See: Container.removeChild
reset world.js:102
reset() → {}

reset the game world

reset world.js:168
reset(dt: number) → {boolean}

update the game world

Parameters:
Name Type Description
dt number

the time passed since the last frame update

Returns:
Type Description
boolean

true if the word is dirty


Powered by webdoc!