me.QuadTree(bounds, max_objectsopt, max_levelsopt, levelopt)

new QuadTree(bounds, max_objectsopt, max_levelsopt, levelopt)

Quadtree Constructor
note: the global quadtree instance is available through me.collision.quadTree

Parameters:
Name Type Attributes Default Description
bounds me.Rect

bounds of the node

max_objects Number <optional>
4

max objects a node can hold before splitting into 4 subnodes

max_levels Number <optional>
4

total max levels inside root Quadtree

level Number <optional>

deepth level, required for subnodes

See:

Extends

  • Object

Methods

static clear()

clear the quadtree

static hasChildren()

return true if the node has any children

Returns:
-

true if the node has any children

static insert(item)

Insert the given object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.

Parameters:
Name Type Description
item Object

object to be added

static insertContainer(container)

Insert the given object container into the node.

Parameters:
Name Type Description
container me.Container

group of objects to be added

static isPrunable()

return true if the node is prunable

Returns:
-

true if the node is prunable

static remove(object)

Remove the given item from the quadtree. (this function won't recalculate the impacted node)

Parameters:
Name Type Description
object Object

object to be removed

Returns:
-

true if the item was found and removed.

static retrieve(object, functionopt) → {Array.<Object>}

Return all objects that could collide with the given object

Parameters:
Name Type Attributes Description
object Object

object to be checked against

function Object <optional>

a sorting function for the returned array

Returns:
Array.<Object> -

array with all detected objects