Hi,
I was just wondering how I could detect a mouse click on an entity (using the entity class in the Space Invaders game, just to help out with this example). I'm not new to Java, but I am to LWJGL and OpenGL. I know that you can use a method in the Mouse class to get co-ordinates and perform actions based on the co-ordinates clicked, but this would take a lot more work than just being able to determine when the entity is clicked on.
Thanks, and sorry if it's not clear enough... I tried :/
have a read of the 5 Part LWJGL Basics Tutorials found on the wiki (http://www.lwjgl.org/wiki/index.php?title=Main_Page). Tutorial 2 of those should explain how to get mouse clicks.
Thank you for such a quick response!
So, I already saw that, and I know what methods to use to get mouse input. But, I don't know how to use that with an entity class - only with getX and getY. I could find all the coordinates that the entity covers and use getX and getY to act upon a mouse click (if that makes sense? It does in my head...) but I was looking for an easier way.
You won't get away from the entity check that easily. Another approach you can try is color picking. That way you define a color for every entity you have and check the color that has been clicked on the specific location.
Okay, thanks, I'll have a go at that.