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

2024/6/29

How to spawn actor somewhere else.

raaeeth raaeeth

2024/6/29

#
After my actor hit another actor, it ends the game (thats what I want). Now what I would like to happen is that after I click the reset button, my actor teleports back to the original spawn. I have the button and everything to reset, except the code for the actor to make him go back as well. How can I make an actor teleport with the push of a button?
danpost danpost

2024/6/30

#
raaeeth wrote...
After my actor hit another actor, it ends the game (thats what I want). Now what I would like to happen is that after I click the reset button, my actor teleports back to the original spawn. I have the button and everything to reset, except the code for the actor to make him go back as well. How can I make an actor teleport with the push of a button?
You should be able to just start a new world (which should be equivalent to a reset). Something like this:
if (Greenfoot.mouseClicked(btnReset)) Greenfoot.setWorld(new MyWorld());
(where btnReset is a reference to your reset button Actor instance).
You need to login to post a reply.