lequ Posted April 13, 2016 Share Posted April 13, 2016 Hello! I have a quick question, I've been searching around for an answer that would work for me but can't find one so here goes; The game I'm trying to make have a targeting system, meaning I can click on another sprite to make my main sprite shot bullets on it, for this I've been using: this.TARGET_SPRITE.events.onInputDown.add(ATTACK_FUNCTION, this); However, this occupy both my mouse buttons, is there a way to use the same method but somehow track which of the input buttons I just pressed down? Do I have to use like "game.input.activePointer.leftButton.isDown" in the update loop or is there a way to create a passive listener like the one I'm using now (but for only one button)? Sorry if it's a stupid question, I'm still learning! Thanks in advance! // Alex Link to comment Share on other sites More sharing options...
kevdude Posted April 18, 2016 Share Posted April 18, 2016 Keep This the same: this.TARGET_SPRITE.events.onInputDown.add(ATTACK_FUNCTION, this); And in the ATTACK_FUNCTION try this: ATTACK_FUNCTION = function(){ if(game.input.mouse.button === Phaser.Mouse.LEFT_BUTTON){ //Code Here } } See more info here. Link to comment Share on other sites More sharing options...
Recommended Posts