flatworld.utils.Quadtree Class
NOTE! NOT IN USE AT THE MOMENT. THIS WAS LESS EFFICIENT THAN USING SUBCONTAINERS, SO IT WILL BE USED IN THE FUTURE IF NEEDED.
This class handles the API for quadtree to search for the wanted objects on the certain coordinates. After this the map should do it's own - more precise - hit detections.
Constructor
Item Index
Methods
Methods
_creteQuadtreeObject
-
coords
-
size
-
data
Parameters:
-
coords
ObjectCoordinates on the global / canvas element.
-
x
IntegerX coordinate
-
y
IntegerY coordinate
-
-
size
ObjectYou can use bounds for the object if you wish, instead of point / coordinates
-
width
IntegerWidth (in pixels)
-
height
IntegerHeight (in pixels)
-
-
data
ObjectExtra data stored for the quadtree object
Returns:
Added quadtree object
add
-
coords
-
size
-
data
Add an object to the quadtree.
Parameters:
Returns:
Quadtree instance
findObject
-
coords
-
size
-
data
Find an object by hitDetection from the quadtree setting.
Parameters:
Returns:
Found object
move
-
coords
-
size
-
data
-
to
Move an object on the quadtree
Parameters:
-
coords
ObjectCoordinates on the global / canvas element.
-
x
IntegerX coordinate
-
y
IntegerY coordinate
-
-
size
ObjectYou can use bounds for the object "hit" detection
-
width
IntegerWidth (in pixels)
-
height
IntegerHeight (in pixels)
-
-
data
ObjectObjects extra custom data. This is optional.
-
to
BooleanShould we refresh the quadtree setting, after removal. Can take some resources to execute. So we want this to be optional.
Returns:
True of false
refreshAll
()
refresh the whole quadtree setting. Can spend some resources.
remove
-
coords
-
size
-
data
-
refresh
Remove an object from the quadtree.
Parameters:
-
coords
ObjectCoordinates on the global / canvas element.
-
x
IntegerX coordinate
-
y
IntegerY coordinate
-
-
size
ObjectYou can use bounds for the object "hit" detection
-
width
IntegerWidth (in pixels)
-
height
IntegerHeight (in pixels)
-
-
data
ObjectObjects extra custom data. This is optional.
-
refresh
BooleanShould we refresh the quadtree setting, after removal. Can take some resources to execute. So we want this to be optional.
Returns:
Quadtree instance