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

2015/9/9

setPaintOrder() not for Classes but for Objects

edik_192 edik_192

2015/9/9

#
Hi, I need some help. Method setPaintOrder() can help to set order of painting of different classes, but how i can set paint order for different objects of same class, which already added to World? Thanks
Super_Hippo Super_Hippo

2015/9/9

#
That isn't possible with this method. I am not sure how it is determined which object will be painted first, but it has probably something to do with the order they were created or added to the world. Edit: I just tried it out. If you remove and readd an object, this object will be on top.
edik_192 edik_192

2015/9/10

#
Thanks. Your variant is good for me. Used:
1
2
3
4
World world = getWorld();
int x = getX(), y = getY();
world.removeObject(this);
world.addObject(this, x, y);
You need to login to post a reply.