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

2012/11/29

how can I add new actors below existing actors?

Griffon Griffon

2012/11/29

#
I know that any new actor is automatically added above all existing actors, but I'm putting roads in my game and I want them to be added later in the game and for them to be added on the bottom level of the actors, I've look through the api for a long time and give up one solution I found that's not effective to move existing actors to the top is to: add a new actor at the same X and Y place then delete the old actor moving it to the top, but it'd be hard to do that with every actor on the world just to place one actor below the rest my solution is as follows: (it's not exactly what I use, I'd replace Actor with the class name and I put this in the actor class I want to move to the top)
1
2
getWorld().addObject(new Actor(),getX(),getY());
getWorld().removeObject(this);
I'm asking if there is an easier way move actors up and down levels easier like the "move to front", "move to back", ect. in microsoft office
Morran Morran

2012/11/29

#
Inside of your world class, you can add a method "setPaintOrder(firstClass.class, secondClass.class, thirdClass.class, ... lastClass.class);" All of your objects that are supposed to be behind, should be last in the list. All of your objects that are supposed to be in front are supposed to be in the beginning of the list. If you don't add a class to that list, it becomes drawn automatically to the back, under everything else. All objects of the same class are added to the same level/layer.
Griffon Griffon

2012/11/29

#
thanks, that's just what I needed :)
Ryan.stephens31 Ryan.stephens31

2016/5/5

#
Morran wrote...
Inside of your world class, you can add a method "setPaintOrder(firstClass.class, secondClass.class, thirdClass.class, ... lastClass.class);"
I'm trying to do this above and am receiving java.lang.NullPointerExeception. Any Ideas what is going on?
danpost danpost

2016/5/5

#
Ryan.stephens31 wrote...
Morran wrote...
Inside of your world class, you can add a method "setPaintOrder(firstClass.class, secondClass.class, thirdClass.class, ... lastClass.class);"
I'm trying to do this above and am receiving java.lang.NullPointerExeception. Any Ideas what is going on?
You should refrain from reviving old discussion thread and create a new one for your issue. Include the code around which the error occurred and copy/paste the complete error message to allow us to determine where the problem resides.
You need to login to post a reply.