Search the Community
Showing results for tags 'priority'.
-
Hi everybody, I'm new in the forum as well in the html5 game developing. That's my problem: I have a sprite with a handler for the onUp event: mySprite = game.add.sprite(width, height, 'unchecked'); mySprite.inputEnabled = true; mySprite.input.useHandCursor = true; mySprite.events.onInputUp.add(function () { //handling... }, this, 0);Some linea above, I have a listener for the game's onUp event game.input.onUp.add(function () { //handling... }, this, 0);I would like to give priority to the sprite's event instead of the game's event. What can I do? Thank you F.
-
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.