Jump to content

Disabling drag / mouse input


onedayitwillmake
 Share

Recommended Posts

I have a game with a level editor, where the user can press a button and switch to play-test state.

Once that happens, I disable the dragging on certain game objects.

 

However I'm running into a problem that leads me to think that the way I'm removing the input handlers is wrong ( more likely ), or there is a bug in phaser (less likely)

 

What's happening it seems is that this bit, seems to be in contradiction with itself:

//  Just run through the linked list        if (this.game.input.interactiveItems.total > 0)        {            var currentNode = this.game.input.interactiveItems.next;            do              {                //  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                if (currentNode.priorityID > this._highestInputPriorityID || (currentNode.priorityID == this._highestInputPriorityID && currentNode.sprite.renderOrderID > this._highestRenderOrderID))                {                    if (currentNode.checkPointerOver(this))                    {

this.game.input.interactiveItems.total is 2, however this.game.input.interactiveItems.next is null right from the first iteration of the loop.

 

Here's an image that may be able to shed some more light.

http://imgur.com/exA7355

 

My add remove code looks a bit like this:

    /**     * Used to re-enable dragging if it [disable] has been called     */    enable: function(){      var view = this.gameObject.getView()      view.inputEnabled = true;      view.events.onDragStart.add( this.onDragStart, this );      view.events.onDragStop.add( this.onDragEnd, this );      view.input.enableDrag(false, false, false, false, null, null );      if( this.snapToGrid ) {        view.input.enableSnap( FlexGame.model.GameConfig.GRID_SIZE, FlexGame.model.GameConfig.GRID_SIZE, true, true );      }    },    /**     * Used to disable dragging temporarily     */    disable: function(){      var view = this.gameObject.getView();      view.inputEnabled = false;      view.events.onDragStart.remove( this.onDragStart, this );      view.events.onDragStop.remove( this.onDragEnd, this );      view.input.disableDrag();    },

Any thoughts?

Link to comment
Share on other sites

Turns out this was a bug in the LinkedList#remove implementation. 

I replaced it with, in a pull request https://github.com/photonstorm/phaser/pull/75

if( child == this.first )  this.first = this.first.next;      // It was 'first', make 'first' point to first.nextelse if ( child == this.last ) this.last = this.last.prev; // It was 'last', make 'last' point to last.prev if( child.prev ) child.prev.next = child.next; // make child.prev.next point to childs.next instead of childif( child.next ) child.next.prev = child.prev; // make child.next.prev point to child.prev instead of childchild.next = child.prev = null; if( this.first == null ) this.last = null; this.total--;
 
 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...