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) → {}
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 from World
Methods from World
Properties inherited from Container
boolean |
|
boolean |
|
Color |
|
boolean |
|
boolean |
|
boolean |
|
string |
|
Properties inherited from Renderable
number |
|
boolean |
|
Container | Entity |
|
ObservableVector2d |
|
boolean |
|
string |
|
Body |
|
Matrix2d |
|
boolean |
|
string |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
Rect | RoundRect | Polygon | Line | Ellipse |
|
string |
|
Function |
|
ObservableVector3d |
|
Color |
|
boolean |
|
Properties inherited from Rect
Methods inherited from Container
Methods inherited from Renderable
Methods inherited from Rect
Rect |
|
Rect |
|
boolean |
|
Rect |
|
boolean |
|
boolean |
|
boolean |
|
Rect |
|
Rect |
|
Polygon |
|
Rect |
|
Methods inherited from Polygon
Public Properties
broadphase: QuadTree
the instance of the game world quadtree used for broadphase
fps: Vector2d = 60
the rate at which the game world is updated, may be greater than or lower than the display fps
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(body: Body) → {World}
Add a physic body to the game world
Name | Type | Description |
---|---|---|
body | Body |
Type | Description |
---|---|
World |
this game world |
removeBody(body: Body) → {World}
Remove a physic body from the game world
Name | Type | Description |
---|---|---|
body | Body |
Type | Description |
---|---|
World |
this game world |
reset(dt: number) → {boolean}
update the game world
Name | Type | Description |
---|---|---|
dt | number |
the time passed since the last frame update |
Type | Description |
---|---|
boolean |
true if the word is dirty |