Jump to content

Click on sprite reflect on things under it


PRSoluções
 Share

Recommended Posts

It seems you are using game.input.onDown for your tilemap clicking, and sprite.events.onInputDown for your sprite clicking.  That, or Phaser internally uses game.input.onDown for the tilemap click detection.  

Either way, you should be able to stop the sprite.events.onInputDown from propagating down to the tilemap with this method.

Link to comment
Share on other sites

Right, the technique should still be the same.  You want to put an invisible sprite directly under your button (and over the tilemap) with the same x,y,height, and width as that button.  Then, configure it to "eat" the input from game.input.onDown so the tilemap never sees it.

Link to comment
Share on other sites

Hi,

After try a lot of thing...no success. I updated to phaser 2.4.7, but the problem still.

Look the image:

https://www.dropbox.com/s/x9fo1zuaaai4upu/Screenshot%202016-04-22%2014.08.47.png?dl=0

 

My code:

context.map.priorityID = ; // HERE

 

var buttonAddBombW = game.cache.getImage('buttonAddBomb').width;
var buttonAddBombH = game.cache.getImage('buttonAddBomb').height;
var buttonAddBombX = game.camera.x;
var buttonAddBombY = game.camera.height - buttonAddBombH;

context.buttonAddBombBG = game.add.sprite(buttonAddBombX, buttonAddBombY, 'connectionState');
context.buttonAddBombBG.fixedToCamera = true;
context.buttonAddBombBG.width = buttonAddBombW;
context.buttonAddBombBG.height = buttonAddBombH;
context.buttonAddBombBG.inputEnabled = true;
context.buttonAddBombBG.input.priorityID = 1; // HERE
context.buttonAddBombBG.tint = 0xFF0000;
context.buttonAddBombBG.backgroundColor = 0xFF0000;
context.groups.hud.add(context.buttonAddBombBG);

context.buttonAddBomb = game.add.button(buttonAddBombX, buttonAddBombY, 'buttonAddBomb', function () {
    if (context.playerCanAddBomb()) {
        context.player.lastAddBombTime = new Date();
        context.sendAddBombCommand(context.player.position.x, context.player.position.y);
    }
}, this, 1, , 1, 1);
context.buttonAddBomb.fixedToCamera = true;
context.buttonAddBomb.priorityID = 2; // HERE
context.groups.hud.add(context.buttonAddBomb);

Nothing :(

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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