@@ -23,10 +23,12 @@ module Phaser {
2323 * @param {Number } height Desired height of this node.
2424 * @param {Number } parent The parent branch or node. Pass null to create a root.
2525 */
26- constructor ( x : number , y : number , width : number , height : number , parent : QuadTree = null ) {
26+ constructor ( manager : Phaser . Physics . PhysicsManager , x : number , y : number , width : number , height : number , parent : QuadTree = null ) {
2727
2828 super ( x , y , width , height ) ;
2929
30+ QuadTree . physics = manager ;
31+
3032 this . _headA = this . _tailA = new Phaser . LinkedList ( ) ;
3133 this . _headB = this . _tailB = new Phaser . LinkedList ( ) ;
3234
@@ -102,6 +104,8 @@ module Phaser {
102104 private _overlapProcessed : bool ;
103105 private _checkObject ;
104106
107+ public static physics : Phaser . Physics . PhysicsManager ;
108+
105109 /**
106110 * Flag for specifying that you want to add an object to the A list.
107111 */
@@ -392,7 +396,7 @@ module Phaser {
392396 {
393397 if ( this . _northWestTree == null )
394398 {
395- this . _northWestTree = new QuadTree ( this . _leftEdge , this . _topEdge , this . _halfWidth , this . _halfHeight , this ) ;
399+ this . _northWestTree = new QuadTree ( QuadTree . physics , this . _leftEdge , this . _topEdge , this . _halfWidth , this . _halfHeight , this ) ;
396400 }
397401
398402 this . _northWestTree . addObject ( ) ;
@@ -403,7 +407,7 @@ module Phaser {
403407 {
404408 if ( this . _southWestTree == null )
405409 {
406- this . _southWestTree = new QuadTree ( this . _leftEdge , this . _midpointY , this . _halfWidth , this . _halfHeight , this ) ;
410+ this . _southWestTree = new QuadTree ( QuadTree . physics , this . _leftEdge , this . _midpointY , this . _halfWidth , this . _halfHeight , this ) ;
407411 }
408412
409413 this . _southWestTree . addObject ( ) ;
@@ -417,7 +421,7 @@ module Phaser {
417421 {
418422 if ( this . _northEastTree == null )
419423 {
420- this . _northEastTree = new QuadTree ( this . _midpointX , this . _topEdge , this . _halfWidth , this . _halfHeight , this ) ;
424+ this . _northEastTree = new QuadTree ( QuadTree . physics , this . _midpointX , this . _topEdge , this . _halfWidth , this . _halfHeight , this ) ;
421425 }
422426
423427 this . _northEastTree . addObject ( ) ;
@@ -428,7 +432,7 @@ module Phaser {
428432 {
429433 if ( this . _southEastTree == null )
430434 {
431- this . _southEastTree = new QuadTree ( this . _midpointX , this . _midpointY , this . _halfWidth , this . _halfHeight , this ) ;
435+ this . _southEastTree = new QuadTree ( QuadTree . physics , this . _midpointX , this . _midpointY , this . _halfWidth , this . _halfHeight , this ) ;
432436 }
433437
434438 this . _southEastTree . addObject ( ) ;
@@ -441,7 +445,7 @@ module Phaser {
441445 {
442446 if ( this . _northWestTree == null )
443447 {
444- this . _northWestTree = new QuadTree ( this . _leftEdge , this . _topEdge , this . _halfWidth , this . _halfHeight , this ) ;
448+ this . _northWestTree = new QuadTree ( QuadTree . physics , this . _leftEdge , this . _topEdge , this . _halfWidth , this . _halfHeight , this ) ;
445449 }
446450
447451 this . _northWestTree . addObject ( ) ;
@@ -451,7 +455,7 @@ module Phaser {
451455 {
452456 if ( this . _northEastTree == null )
453457 {
454- this . _northEastTree = new QuadTree ( this . _midpointX , this . _topEdge , this . _halfWidth , this . _halfHeight , this ) ;
458+ this . _northEastTree = new QuadTree ( QuadTree . physics , this . _midpointX , this . _topEdge , this . _halfWidth , this . _halfHeight , this ) ;
455459 }
456460
457461 this . _northEastTree . addObject ( ) ;
@@ -461,7 +465,7 @@ module Phaser {
461465 {
462466 if ( this . _southEastTree == null )
463467 {
464- this . _southEastTree = new QuadTree ( this . _midpointX , this . _midpointY , this . _halfWidth , this . _halfHeight , this ) ;
468+ this . _southEastTree = new QuadTree ( QuadTree . physics , this . _midpointX , this . _midpointY , this . _halfWidth , this . _halfHeight , this ) ;
465469 }
466470
467471 this . _southEastTree . addObject ( ) ;
@@ -471,7 +475,7 @@ module Phaser {
471475 {
472476 if ( this . _southWestTree == null )
473477 {
474- this . _southWestTree = new QuadTree ( this . _leftEdge , this . _midpointY , this . _halfWidth , this . _halfHeight , this ) ;
478+ this . _southWestTree = new QuadTree ( QuadTree . physics , this . _leftEdge , this . _midpointY , this . _halfWidth , this . _halfHeight , this ) ;
475479 }
476480
477481 this . _southWestTree . addObject ( ) ;
@@ -621,7 +625,8 @@ module Phaser {
621625 continue ;
622626 }
623627
624- if ( QuadTree . _object . body . bounds . checkHullIntersection ( this . _checkObject . body . bounds ) )
628+ //if (QuadTree._object.body.bounds.checkHullIntersection(this._checkObject.body.bounds))
629+ if ( QuadTree . physics . checkHullIntersection ( QuadTree . _object . body , this . _checkObject . body ) )
625630 {
626631 //Execute callback functions if they exist
627632 if ( ( QuadTree . _processingCallback == null ) || QuadTree . _processingCallback ( QuadTree . _object , this . _checkObject ) )
0 commit comments