I'm making a game rendered in a trimetric perspective (like isometric, but one set of tile sides is steeper than the other). I want to add functionality for when the mouse rolls over tiles or objects (highlighting, pop-ups and the like).
Both the objects and tiles will have complicated shapes, and I'm looking for the best way to mark when the mouse passes over them, especially since top-most objects should take precedence over background objects.
Currently, the tiles and objects are rendered by the Graphics.drawImage
function on a canvas after being loaded as buffered images, for every frame.
I keep seeing mouseEvent.getSource
on the alternate explanations, but it seems to require creating graphics objects for every highlightable object. I'm concerned this may be inefficient when hundreds of objects and tiles are on the screen that can be potentially selected.
Specifically, my questions are these:
Is creating hundreds, if not thousands, of graphics objects per frame a bad way to use the getSource function?
Is there a better way to determine which instance of a class is being selected, given mouse coordinates? Such as a separate array of all pixels and the object/tile ID to which they belong (I estimated the size to be close to 3 MB, with constant updating as the screen moves around)?