Jump to content

Input priorityID problem.


XekeDeath
 Share

Recommended Posts

As usual, I am on the absolute latest Phaser.

I have a GUI with some buttons that pops up over the game world, and ideally the player should be able to click the buttons without interacting with the game world underneath.

 

Simple, I think, I'll use the priorityID value, because this is exactly what it is for!

Sadly, it is not working for me.

 

I have these 2 objects:

PolicyButton:

//This is the constructor of the buttons on the GUI that should be firing their callback.PolicyButton = function(game, policy){    Phaser.Image.call(this, game, 0, 0, "sprites", policy+"_disabled");    this.enabled = true;    this.active = false;    this.visible = false;    this.policy = policy;       this.inputEnabled = true;    this.input.priorityID = 100;    this.events.onInputDown.add(this.onClick, this);};

Building:

//This is in the create function of the main Game State. Building is derived from Phaser.Image, like the PolicyButton is.//but the input handling is created here in the game state instead of the constructor.building.inputEnabled = true;//Has to be pixel perfect so we don't select something we should not...building.input.pixelPerfectClick = true;building.input.priorityID = 50;//Display stuff in the GUI when we click a building...building.events.onInputDown.add(this.displayBuilding, this);

The behaviour I am getting is that regardless of what priorityID I set on the objects, the building objects callback is always firing, and the GUI button callback is not.

It should be the other way around.

 

In terms of creation order, the buildings are created first, the policy buttons are created later.

 

 

*Note that I am only referring to cases where the input click is directly over both a GUI button and a building in the game world. Buttons behave as expected at all other times.

 

Link to comment
Share on other sites

This appears to be some sort of conflict between pixel perfect clicking and the priorityIDs.

I commented out the line that made building selection pixel perfect, and now the priorityIDs seem to be working as intended.

 

 

Edit: Looked at the Phaser code and found this:

Phaser.Pointer, Line 370:

if (currentNode.pixelPerfectClick || currentNode.pixelPerfectOver || currentNode.priorityID > this._highestInputPriorityID || (currentNode.priorityID === this._highestInputPriorityID && currentNode.sprite._cache[3] < this._highestRenderOrderID))

So if the image is pixelPerfect enabled, OR it has a higher priority, then treat it as on top. This is what is breaking my GUI.

Link to comment
Share on other sites

  • 4 months later...
 Share

  • Recently Browsing   0 members

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