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

2018/5/27

How to hide all objects at once?

spacefrags spacefrags

2018/5/27

#
I'm trying to hide all objects at once and I know about the "getImage().setTransparency(0);" method, but I do not know how to apply it to all of the objects. How could I do it?
danpost danpost

2018/5/27

#
spacefrags wrote...
I'm trying to hide all objects at once and I know about the "getImage().setTransparency(0);" method, but I do not know how to apply it to all of the objects. How could I do it?
Just iterate through all actors in the world and execute the code on each one:
// in world class
for (Object obj : getObjects(null)) ((Actor)obj).getImage().setTransparency(0);
// from actor class, start with:
for (Object obj : getWorld().getObjects(null))
Be aware that even if their images are transparent (if the actors are hidden), they will still act (or behave) the same.
spacefrags spacefrags

2018/5/27

#
Thank you very much, it works perfectly now!
You need to login to post a reply.