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

2023/3/20

How to add actors in the same place as before

RandomGuy RandomGuy

2023/3/20

#
Hey Guys, Do any of you lot know how to add actors(in the same starting place) once they have been removed? Please tell me the code on this,if you can! In this case, I want to remove my "Zombies"(zombies is actual actor) and add it in the same position (I have coordinates so dont worry about that)
danpost danpost

2023/3/21

#
RandomGuy wrote...
Do any of you lot know how to add actors(in the same starting place) once they have been removed?
The easiest way is to place the following code in your World subclass:
public void removeObject(Actor actor)
{
    super.removeObject(actor);
    if (actor instanceof Zombies) addObject(new Zombies(), /** wherever */);
}
RandomGuy RandomGuy

2023/3/21

#
Dude thank you so much!
You need to login to post a reply.