This site requires JavaScript, please enable it in your browser!
Greenfoot back
MrDoomsday
MrDoomsday wrote ...

2012/5/16

Changing importance of overlapping objects

MrDoomsday MrDoomsday

2012/5/16

#
When the images of some of my objects overlap only one of them is shown because it is more in the foreground. How can I swap them so the other object is actually in the foreground when it tries to overlap another object?
danpost danpost

2012/5/16

#
If they are of different 'type's, and you always want one 'type' above another, you can use the setPaintOrder method in the World class (that is the easy one to arrange). If they are of different 'type's, but do not always want one 'type' above the other, or if they are of the same type, you can arrange them as needed on the fly. You accomplish this by taking the object you want to be above the other, and after saving its getX() and getY() in variables, remove it from the world and re-insert it at the same location by using the co-ordinates you had saved.
MrDoomsday MrDoomsday

2012/5/16

#
Thanks! This answer is exactly what I was looking for.
You need to login to post a reply.