PRSoluções Posted April 20, 2016 Share Posted April 20, 2016 Hi, I have a problem that i think be simple. When i click on a button/sprite, the tilemap is clicked too. I want that the click on button/sprite not reflect on tilemap. https://www.dropbox.com/s/malml7b8vhuyeum/Screenshot%202016-04-20%2013.41.30.png?dl=0 Thanks. Link to comment Share on other sites More sharing options...
Cudabear Posted April 20, 2016 Share Posted April 20, 2016 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 More sharing options...
PRSoluções Posted April 22, 2016 Author Share Posted April 22, 2016 Hi, But with that example, i need create a sprite with full size and i need the click on tilemap. I dont want only that the click thought the button sprite. Link to comment Share on other sites More sharing options...
Cudabear Posted April 22, 2016 Share Posted April 22, 2016 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 More sharing options...
WombatTurkey Posted April 22, 2016 Share Posted April 22, 2016 I believe you're looking for Input Priority: http://phaser.io/examples/v2/input/input-priority perhaps? Link to comment Share on other sites More sharing options...
PRSoluções Posted April 22, 2016 Author Share Posted April 22, 2016 Hi, I already changed the priority. I put on tilemap = 0 and on button = 1. The same result. Ty. Link to comment Share on other sites More sharing options...
PRSoluções Posted April 22, 2016 Author Share Posted April 22, 2016 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 More sharing options...
PRSoluções Posted April 22, 2016 Author Share Posted April 22, 2016 And to get tilemap click, im using today: else if (game.input.activePointer.isDown) { var currentTile = this.map.getTile(this.floorLayer.getTileX(game.input.activePointer.worldX), this.floorLayer.getTileY(game.input.activePointer.worldY)); if (currentTile) { Can anyone help me? Link to comment Share on other sites More sharing options...
PRSoluções Posted April 26, 2016 Author Share Posted April 26, 2016 Please help me The click thought button already happen. My code is above. https://www.dropbox.com/s/w7fwdf3jjtogp7n/Screenshot%202016-04-26%2013.56.12.png?dl=0 Link to comment Share on other sites More sharing options...
PRSoluções Posted April 27, 2016 Author Share Posted April 27, 2016 Help me Link to comment Share on other sites More sharing options...
Recommended Posts