- Psykick2D
QuadTree
Keeps track of all the physical objects in space
new QuadTree(
options
)
Parameters
options | object | ||
options.x | number | X position | |
options.y | number | Y position | |
options.width | number | Width | |
options.height | number | Height | |
options.cellSize | number | Size of a cell | |
options.componentType | string | Component to use as a rectangle | 'Rectangle' |
Properties
x | number | ||
y | number | ||
width | number | ||
height | number | ||
children | Array | new Array() | |
entities | ARRAY | [] |
Methods
addEntity( )
Adds an entity to the tree
entity | Entity | ||
rect | Rectangle |
removeEntity( )
Removes an Entity from the tree
entity | Entity | ||
rect | Rectangle |
moveEntity( )
Moves an Entity and updates it's position in the tree
entity | Entity | ||
deltaPosition |
Entity[] getCollisions( )
Returns all entities the given entity is colliding with
entity | Entity | ||
rect | Rectangle |