@@ -362,7 +362,7 @@ Phaser.Pointer.prototype = {
362362
363363 // Work out which object is on the top
364364 this . _highestRenderOrderID = - 1 ;
365- this . _highestRenderObject = - 1 ;
365+ this . _highestRenderObject = null ;
366366 this . _highestInputPriorityID = - 1 ;
367367
368368 // Just run through the linked list
@@ -372,9 +372,12 @@ Phaser.Pointer.prototype = {
372372
373373 do
374374 {
375- if ( currentNode [ 'update' ] )
375+ // If the object has a higher InputManager.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top
376+ if ( currentNode . priorityID > this . _highestInputPriorityID || ( currentNode . priorityID == this . _highestInputPriorityID && currentNode . sprite . renderOrderID > this . _highestRenderOrderID ) && currentNode . checkPointerOver ( this ) )
376377 {
377- currentNode . update ( ) ;
378+ this . _highestRenderOrderID = currentNode . sprite . renderOrderID ;
379+ this . _highestInputPriorityID = currentNode . priorityID ;
380+ this . _highestRenderObject = currentNode ;
378381 }
379382
380383 currentNode = currentNode . next ;
@@ -383,6 +386,7 @@ Phaser.Pointer.prototype = {
383386 }
384387
385388
389+ /*
386390 for (var i = 0; i < this.game.input.totalTrackedObjects; i++)
387391 {
388392 if (this.game.input.inputObjects[i] && this.game.input.inputObjects[i].input && this.game.input.inputObjects[i].input.checkPointerOver(this))
@@ -396,13 +400,14 @@ Phaser.Pointer.prototype = {
396400 }
397401 }
398402 }
403+ */
399404
400- if ( this . _highestRenderObject == - 1 )
405+ if ( this . _highestRenderObject == null )
401406 {
402- // The pointer isn't over anything, check if we've got a lingering previous target
403- if ( this . targetObject !== null )
407+ // The pointer isn't currently over anything, check if we've got a lingering previous target
408+ if ( this . targetObject )
404409 {
405- this . targetObject . input . _pointerOutHandler ( this ) ;
410+ this . targetObject . _pointerOutHandler ( this ) ;
406411 this . targetObject = null ;
407412 }
408413 }
@@ -411,28 +416,28 @@ Phaser.Pointer.prototype = {
411416 if ( this . targetObject == null )
412417 {
413418 // And now set the new one
414- this . targetObject = this . game . input . inputObjects [ this . _highestRenderObject ] ;
415- this . targetObject . input . _pointerOverHandler ( this ) ;
419+ this . targetObject = this . _highestRenderObject ;
420+ this . _highestRenderObject . _pointerOverHandler ( this ) ;
416421 }
417422 else
418423 {
419424 // We've got a target from the last update
420- if ( this . targetObject == this . game . input . inputObjects [ this . _highestRenderObject ] )
425+ if ( this . targetObject == this . _highestRenderObject )
421426 {
422427 // Same target as before, so update it
423- if ( this . targetObject . input . update ( this ) == false )
428+ if ( this . _highestRenderObject . update ( this ) == false )
424429 {
425430 this . targetObject = null ;
426431 }
427432 }
428433 else
429434 {
430435 // The target has changed, so tell the old one we've left it
431- this . targetObject . input . _pointerOutHandler ( this ) ;
436+ this . targetObject . _pointerOutHandler ( this ) ;
432437
433438 // And now set the new one
434- this . targetObject = this . game . input . inputObjects [ this . _highestRenderObject ] ;
435- this . targetObject . input . _pointerOverHandler ( this ) ;
439+ this . targetObject = this . _highestRenderObject ;
440+ this . targetObject . _pointerOverHandler ( this ) ;
436441 }
437442 }
438443 }
@@ -506,17 +511,22 @@ Phaser.Pointer.prototype = {
506511 this . game . input . currentPointers -- ;
507512 }
508513
509- for ( var i = 0 ; i < this . game . input . totalTrackedObjects ; i ++ )
514+ if ( this . game . input . interactiveItems . next )
510515 {
511- if ( this . game . input . inputObjects [ i ] && this . game . input . inputObjects [ i ] . input && this . game . input . inputObjects [ i ] . input . enabled )
516+ var currentNode = this . game . input . interactiveItems . next ;
517+
518+ do
512519 {
513- this . game . input . inputObjects [ i ] . input . _releasedHandler ( this ) ;
520+ currentNode . _releasedHandler ( this ) ;
521+
522+ currentNode = currentNode . next ;
514523 }
524+ while ( currentNode != this . game . input . interactiveItems . next )
515525 }
516526
517527 if ( this . targetObject )
518528 {
519- this . targetObject . input . _releasedHandler ( this ) ;
529+ this . targetObject . _releasedHandler ( this ) ;
520530 }
521531
522532 this . targetObject = null ;
@@ -532,7 +542,7 @@ Phaser.Pointer.prototype = {
532542 */
533543 justPressed : function ( duration ) {
534544
535- if ( typeof duration === "undefined" ) { duration = this . game . input . justPressedRate ; }
545+ duration = duration || this . game . input . justPressedRate ;
536546
537547 return ( this . isDown === true && ( this . timeDown + duration ) > this . game . time . now ) ;
538548
@@ -546,7 +556,7 @@ Phaser.Pointer.prototype = {
546556 */
547557 justReleased : function ( duration ) {
548558
549- if ( typeof duration === "undefined" ) { duration = this . game . input . justReleasedRate ; }
559+ duration = duration || this . game . input . justReleasedRate ;
550560
551561 return ( this . isUp === true && ( this . timeUp + duration ) > this . game . time . now ) ;
552562
@@ -571,9 +581,9 @@ Phaser.Pointer.prototype = {
571581 this . _history . length = 0 ;
572582 this . _stateReset = true ;
573583
574- if ( this . targetObject && this . targetObject . input )
584+ if ( this . targetObject )
575585 {
576- this . targetObject . input . _releasedHandler ( this ) ;
586+ this . targetObject . _releasedHandler ( this ) ;
577587 }
578588
579589 this . targetObject = null ;
0 commit comments