I'm trying to detect in memory, when user invade mouse on some object, like tree. But checking each pixel is too low, and another problem is that my tree.png have size 64x64, but real tree is smaller, and i was trying to get array of pixels, who's real image. My game is in isometric projection. And is there any good way, to detect when user invade mouse on object?
You can assign each object a coordinate. Then you calculate the distance between mouse and object. If the distance is less than the mouse radius, then the objects overlap or touch.
Second possibility:
You assign each object a bounding box (rectangle around center of object).
Then you check wheter the rectangles intersect. (see Rectangle2D
)