Counting clicks on images

I’m making a game where there needs to be a counter for every time I click on a certain image.
I’ve loaded in the image and set up the counter but I’m not sure how to go about putting details in the void mouseClicked area.

You will need to compare the position of the mouse with the size and position of the image.

The mouse click is always at (mouseX, mouseY).

Where is your image? How wide is it? How high?

What four conditions must be true for the mouse to be on the image?

If all of those for conditions are met when the mouse is clicked, what happens to the counter?

1 Like