HugoMM Posted July 22, 2018 Share Posted July 22, 2018 I have an image A as a button, a smaller image B on top it. How do I trigger the click event handler of A, when the mouse click on B? Link to comment Share on other sites More sharing options...
rich Posted July 22, 2018 Share Posted July 22, 2018 We use ee3 for events in v3 and it doesn't have support for triggering events. The easiest thing to do would be to simply call the image A callback within the image B callback. Or don't have an event on image B at all and just let the button A deal with it? Link to comment Share on other sites More sharing options...
HugoMM Posted July 22, 2018 Author Share Posted July 22, 2018 I don't have any event handler on image B(because there could be many images like B), but B is preventing A getting mouse click Link to comment Share on other sites More sharing options...
rich Posted July 22, 2018 Share Posted July 22, 2018 If image B has not been enabled for input, it's literally impossible for it to prevent any other image from receiving input events. Images that have not been input enabled are completely ignored by the input system and do not block anything. I would double-check your code. Either that, or there's something else going on here that hasn't been explained fully in your post. Link to comment Share on other sites More sharing options...
NoxBrutalis Posted July 22, 2018 Share Posted July 22, 2018 Yes, indeed - what Rich said. The only thing I can think of without seeing any code is that you're not setting the buttons up correctly for Phaser? Should look something like this: this.button = this.add.sprite(xy.x, xy.y - 96, 'start').setInteractive(); this.button.on('pointerover', function(){this.button.setTint(0xf0ff00);}, this) this.button.on('pointerout', function(){this.button.setTint(0xffffff);}, this) this.button.on('pointerdown', function(){ //do things on click }); Link to comment Share on other sites More sharing options...
HugoMM Posted July 24, 2018 Author Share Posted July 24, 2018 @Rich is right, Thanks for the insights. I used one function to create all the images, so they were all interactive. Link to comment Share on other sites More sharing options...
brentstrandy Posted July 24, 2018 Share Posted July 24, 2018 Can't you use emit? To use NoxBrutalis' example: this.button = this.add.sprite(xy.x, xy.y - 96, 'start').setInteractive(); this.button.on('pointerover', function(){this.button.setTint(0xf0ff00);}, this) this.button.on('pointerout', function(){this.button.setTint(0xffffff);}, this) this.button.on('pointerdown', function(){ //do things on click }); // This line calls the function associated with the button's 'pointerdown' event this.button.emit('pointerdown'); Link to comment Share on other sites More sharing options...
Recommended Posts