Class: QuadTree

QuadTree

FM.QuadTree

new QuadTree(pLevel, pBounds)

The quad tree is used to subdivide the game space to optimize the performance for collisions testing.
Parameters:
Name Type Description
pLevel int The level of depth of the quad tree to create.
pBounds FM.Rectangle The rectangle delimiting the quad tree in the screen space.
Author:
  • Simon Chauvin
Source:

Methods

clear()

Clears the quadtree.
Source:

destroy()

Destroy the quad tree.
Source:

insert(gameObject)

/* Insert the object into the quadtree. If the node exceeds the capacity, it will split and add all objects to their corresponding nodes.
Parameters:
Name Type Description
gameObject FM.GameObject The game object to insert in the quad tree.
Source:

remove(gameObject)

/* Remove the object from the quadtree.
Parameters:
Name Type Description
gameObject FM.GameObject The game object to insert in the quad tree.
Source:

retrieve(gameObject) → {Array}

/* Return all objects that could collide with the given object.
Parameters:
Name Type Description
gameObject FM.GameObject The game object to test if it can collide with any other object.
Source:
Returns:
The list of objects that can collide with the given one.
Type
Array