We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I have a sketch that draws multiple images. I have an array of custom type, the type contains the parameters (image, x, y, width, height). I want to check for overlap between all images drawn (already done) but I want it to be so that if there is an overlap, draw the image last selected on top. How do I incorporate the output of the overlap checking function with the draw() function?
Answers
Either sort the array based on the order they were sorted, or include a Z index that you use with a 3D renderer. Try something out, post some code, and we'll go from there.
Thank you for your reply. I'm having a hard time deciding which of these methods helps; the sorting would have to happen everytime an image is clicked. The I'm attaching the code
Right, the sorting would have to happen every time an image is clicked.
Rather, you'd simply move the image that was most recently clicked to the front of the array.
There are also data structures in Java that would help maintain this order.
So it's not really a matter of sorting every single time, but rather maintaining the sort order.