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

2016/6/24

Need an actor to always be on top visually.

Reaper47 Reaper47

2016/6/24

#
I understand that if an actor is spawned into the world that they are the visually on top of any other actors spawned before. However I need an actor to always be on top even if another actor (of different class) is spawned afterwards. Is that possible in greenfoot without respawning the actor? Because if the actor is respawned it will reset a lot of values I have to preserve within it.
SPower SPower

2016/6/24

#
It is possible, using the setPaintOrder method in world. In the world's constructor, add something like this:
setPaintOrder(ActorToBeOnTop.class);
You could specify the order in which they need to appear, the first one being the type that will be displayed on top of following ones, but if I'm not mistaken, specifying only one class will ensure it will get drawn on top of all the others.
Reaper47 Reaper47

2016/6/24

#
SPower wrote...
It is possible, using the setPaintOrder method in world. In the world's constructor, add something like this:
setPaintOrder(ActorToBeOnTop.class);
You could specify the order in which they need to appear, the first one being the type that will be displayed on top of following ones, but if I'm not mistaken, specifying only one class will ensure it will get drawn on top of all the others.
I'll tweak around with this and look more into it if needed. Thank you.
You need to login to post a reply.