Packageorg.flixel.system
Classpublic class FlxQuadTree
InheritanceFlxQuadTree Inheritance FlxRect Inheritance Object

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!



Public Properties
 PropertyDefined By
 Inheritedbottom : Number
[read-only] The Y coordinate of the bottom of the rectangle.
FlxRect
  divisions : uint
[static] Controls the granularity of the quad tree.
FlxQuadTree
 Inheritedheight : Number
FlxRect
 Inheritedleft : Number
[read-only] The X coordinate of the left side of the rectangle.
FlxRect
 Inheritedright : Number
[read-only] The X coordinate of the right side of the rectangle.
FlxRect
 Inheritedtop : Number
[read-only] The Y coordinate of the top of the rectangle.
FlxRect
 Inheritedwidth : Number
FlxRect
 Inheritedx : Number
FlxRect
 Inheritedy : Number
FlxRect
Protected Properties
 PropertyDefined By
  _b : Number
FlxQuadTree
  _canSubdivide : Boolean
Whether this branch of the tree can be subdivided or not.
FlxQuadTree
  _coh : Number
[static]
FlxQuadTree
  _cow : Number
[static]
FlxQuadTree
  _cox : Number
[static]
FlxQuadTree
  _coy : Number
[static]
FlxQuadTree
  _headA : FlxList
These variables refer to the internal A and B linked lists, which are used to store objects in the leaves.
FlxQuadTree
  _headB : FlxList
FlxQuadTree
  _hh : Number
FlxQuadTree
  _hw : Number
FlxQuadTree
  _l : Number
FlxQuadTree
  _min : uint
[static] These variables refer to the potential child quadrants for this node.
FlxQuadTree
  _mx : Number
FlxQuadTree
  _my : Number
FlxQuadTree
  _ne : FlxQuadTree
FlxQuadTree
  _nw : FlxQuadTree
FlxQuadTree
  _o : FlxObject
[static] These objects are used to reduce recursive parameters internally.
FlxQuadTree
  _oa : uint
[static]
FlxQuadTree
  _ob : Number
[static]
FlxQuadTree
  _ohh : Number
[static]
FlxQuadTree
  _ohw : Number
[static]
FlxQuadTree
  _ohx : Number
[static]
FlxQuadTree
  _ohy : Number
[static]
FlxQuadTree
  _ol : Number
[static]
FlxQuadTree
  _om : Boolean
[static]
FlxQuadTree
  _on : Function
[static]
FlxQuadTree
  _op : Function
[static]
FlxQuadTree
  _or : Number
[static]
FlxQuadTree
  _ot : Number
[static]
FlxQuadTree
  _r : Number
FlxQuadTree
  _se : FlxQuadTree
FlxQuadTree
  _sw : FlxQuadTree
FlxQuadTree
  _t : Number
FlxQuadTree
  _tailA : FlxList
FlxQuadTree
  _tailB : FlxList
FlxQuadTree
Public Methods
 MethodDefined By
  
FlxQuadTree(X:Number, Y:Number, Width:Number, Height:Number, Parent:FlxQuadTree = null)
Instantiate a new Quad Tree node.
FlxQuadTree
  
add(ObjectOrGroup:FlxBasic, List:uint):void
Call this function to add an object to the root of the tree.
FlxQuadTree
 Inherited
FlxRect
 Inherited
copyFromFlash(FlashRect:Rectangle):FlxRect
FlxRect
 Inherited
FlxRect
 Inherited
copyToFlash(FlashRect:Rectangle):Rectangle
FlxRect
  
destroy():void
FlxQuadTree
  
execute():Boolean
FlxQuadTree's other main function.
FlxQuadTree
  
load(ObjectOrGroup1:FlxBasic, ObjectOrGroup2:FlxBasic = null, NotifyCallback:Function = null, ProcessCallback:Function = null):void
FlxQuadTree
 Inherited
make(X:Number = 0, Y:Number = 0, Width:Number = 0, Height:Number = 0):FlxRect
Instantiate a new rectangle.
FlxRect
 Inherited
overlaps(Rect:FlxRect):Boolean
Checks to see if some FlxObject object overlaps this FlxObject object.
FlxRect
Protected Methods
 MethodDefined By
  
addObject():void
Internal function for recursively navigating and creating the tree while adding objects to the appropriate nodes.
FlxQuadTree
  
addToList():void
Internal function for recursively adding objects to leaf lists.
FlxQuadTree
  
overlapNode(Iterator:FlxList = null):Boolean
An internal function for comparing an object against the contents of a node.
FlxQuadTree
Public Constants
 ConstantDefined By
  A_LIST : uint = 0
[static] Flag for specifying that you want to add an object to the A list.
FlxQuadTree
  B_LIST : uint = 1
[static] Flag for specifying that you want to add an object to the B list.
FlxQuadTree
Property Detail
_bproperty
protected var _b:Number

_canSubdivideproperty 
protected var _canSubdivide:Boolean

Whether this branch of the tree can be subdivided or not.

_cohproperty 
protected static var _coh:Number

_cowproperty 
protected static var _cow:Number

_coxproperty 
protected static var _cox:Number

_coyproperty 
protected static var _coy:Number

_headAproperty 
protected var _headA:FlxList

These variables refer to the internal A and B linked lists, which are used to store objects in the leaves.

_headBproperty 
protected var _headB:FlxList

_hhproperty 
protected var _hh:Number

_hwproperty 
protected var _hw:Number

_lproperty 
protected var _l:Number

_minproperty 
protected static var _min:uint

These variables refer to the potential child quadrants for this node.

_mxproperty 
protected var _mx:Number

_myproperty 
protected var _my:Number

_neproperty 
protected var _ne:FlxQuadTree

_nwproperty 
protected var _nw:FlxQuadTree

_oproperty 
protected static var _o:FlxObject

These objects are used to reduce recursive parameters internally.

_oaproperty 
protected static var _oa:uint

_obproperty 
protected static var _ob:Number

_ohhproperty 
protected static var _ohh:Number

_ohwproperty 
protected static var _ohw:Number

_ohxproperty 
protected static var _ohx:Number

_ohyproperty 
protected static var _ohy:Number

_olproperty 
protected static var _ol:Number

_omproperty 
protected static var _om:Boolean

_onproperty 
protected static var _on:Function

_opproperty 
protected static var _op:Function

_orproperty 
protected static var _or:Number

_otproperty 
protected static var _ot:Number

_rproperty 
protected var _r:Number

_seproperty 
protected var _se:FlxQuadTree

_swproperty 
protected var _sw:FlxQuadTree

_tproperty 
protected var _t:Number

_tailAproperty 
protected var _tailA:FlxList

_tailBproperty 
protected var _tailB:FlxList

divisionsproperty 
public static var divisions:uint

Controls the granularity of the quad tree. Default is 6 (decent performance on large and small worlds).

Constructor Detail
FlxQuadTree()Constructor
public function FlxQuadTree(X:Number, Y:Number, Width:Number, Height:Number, Parent:FlxQuadTree = null)

Instantiate a new Quad Tree node.

Parameters
X:Number — The X-coordinate of the point in space.
 
Y:Number — The Y-coordinate of the point in space.
 
Width:Number — Desired width of this node.
 
Height:Number — Desired height of this node.
 
Parent:FlxQuadTree (default = null) — The parent branch or node. Pass null to create a root.
Method Detail
add()method
public function add(ObjectOrGroup:FlxBasic, List:uint):void

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.

Parameters

ObjectOrGroup:FlxBasic — FlxObjects are just added, FlxGroups are recursed and their applicable members added accordingly.
 
List:uint — A uint flag indicating the list to which you want to add the objects. Options are A_LIST and B_LIST.

addObject()method 
protected function addObject():void

Internal function for recursively navigating and creating the tree while adding objects to the appropriate nodes.

addToList()method 
protected function addToList():void

Internal function for recursively adding objects to leaf lists.

destroy()method 
public function destroy():void

execute()method 
public function execute():Boolean

FlxQuadTree's other main function. Call this after adding objects using FlxQuadTree.add() to compare the objects that you loaded.

Returns
Boolean — Whether or not any overlaps were found.
load()method 
public function load(ObjectOrGroup1:FlxBasic, ObjectOrGroup2:FlxBasic = null, NotifyCallback:Function = null, ProcessCallback:Function = null):void

Parameters

ObjectOrGroup1:FlxBasic
 
ObjectOrGroup2:FlxBasic (default = null)
 
NotifyCallback:Function (default = null)
 
ProcessCallback:Function (default = null)

overlapNode()method 
protected function overlapNode(Iterator:FlxList = null):Boolean

An internal function for comparing an object against the contents of a node.

Parameters

Iterator:FlxList (default = null) — An optional pointer to a linked list entry (for comparing A against itself).

Returns
Boolean — Whether or not any overlaps were found.
Constant Detail
A_LISTConstant
public static const A_LIST:uint = 0

Flag for specifying that you want to add an object to the A list.

B_LISTConstant 
public static const B_LIST:uint = 1

Flag for specifying that you want to add an object to the B list.