The game I am developing is in which you defend the Cell from the Viruses, and I need the sprites to have a
MouseListener for when the mouse clicks on that
sprite, it will get destroyed, and I cannot figure out how to get the location of the mouse and apply it to the sprite.
Basically, I need to grab the location of the
mouse and the
sprite, and when the user clicks it will reset the
I have tried to do debugging with this, so like if the mouse hovers the location of the sprite it will print a message "Hovering" but it just doesn't work.
For my update method, I added:
if(MouseInfo.getPointerInfo().getLocation() == this.getLocation()) System.out.println("SAME LOCATION");
I even got it to print out the location of the sprite and the mouse, and I aligned them both to
0 and it still didn't work.
How do I check if the location of the mouse is the same as a sprite, and then print out a message to the console?