A fairly generic quad tree structure for rapid overlap checks. FlxQuadTree is also configured for single or dual list operation. You can add items either to its A list or its B list. When you do an overlap check, you can compare the A list to itself, or the A list against the B list. Handy for different things!
Flag for specifying that you want to add an object to the A list.
Flag for specifying that you want to add an object to the B list.
static_NUM_CACHED_QUAD_TREES:Int = 0
Pooling mechanism, turn FlxQuadTree into a linked list, when FlxQuadTrees are destroyed, they get added to the list, and when they get recycled they get removed.
Clear cached Quad Tree nodes. You might want to do this when loading new levels (probably not though, no need to clear cache unless you run into memory problems).
staticrecycle(X:Float, Y:Float, Width:Float, Height:Float, ?Parent:FlxQuadTree):FlxQuadTree
Recycle a cached Quad Tree node, or creates a new one if needed.
The X-coordinate of the point in space.
The Y-coordinate of the point in space.
Desired width of this node.
Desired height of this node.
The parent branch or node. Pass null to create a root.
Call this function to add an object to the root of the tree. This function will recursively add all group members, but not the groups themselves.
FlxObjects are just added, FlxGroups are recursed and their applicable members added accordingly.
A int flag indicating the list to which you want to add the objects. Options are A_LIST and B_LIST.
FlxQuadTree's other main function. Call this after adding objects using FlxQuadTree.load() to compare the objects that you loaded.
Whether or not any overlaps were found.
load(ObjectOrGroup1:FlxBasic, ?ObjectOrGroup2:FlxBasic, ?NotifyCallback:(FlxObject, FlxObject) ‑> Void, ?ProcessCallback:(FlxObject, FlxObject) ‑> Bool):Void
Load objects and/or groups into the quad tree, and register notify and processing callbacks.
Any object that is or extends FlxObject or FlxGroup.
Any object that is or extends FlxObject or FlxGroup. If null, the first parameter will be checked against itself.
A function with the form myFunction(Object1:FlxObject,Object2:FlxObject):void that is called whenever two objects are found to overlap in world space, and either no ProcessCallback is specified, or the ProcessCallback returns true.
A function with the form myFunction(Object1:FlxObject,Object2:FlxObject):Boolean that is called whenever two objects are found to overlap in world space. The NotifyCallback is only called if this function returns true. See FlxObject.separate().