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

2019/10/22

How can I spawn actors for a 5 second and then removed them and replace with others

BestMannCZ BestMannCZ

2019/10/22

#
Hi, I need help. I create actor called Vosa and I want spawn 15x Vosa on random position and after 5 seconds I wanna removed them and spawend another 15x Vosa, can you help me pls ?
BestMannCZ BestMannCZ

2019/10/22

#
And after this will countinue 60 second, it will stopped game
danpost danpost

2019/10/22

#
BestMannCZ wrote...
Hi, I need help. I create actor called Vosa and I want spawn 15x Vosa on random position and after 5 seconds I wanna removed them and spawend another 15x Vosa, can you help me pls ?
First create a method to spawn one at any random location. Show method here to continue.
BestMannCZ BestMannCZ

2019/10/26

#
public class MyWorld extends greenfoot.World { public void pridejVosu() // pridej = add { Vosa v = new Vosa(); int x = Greenfoot.getRandomNumber(this.getWidth()); int y = Greenfoot.getRandomNumber(this.getHeight()); this.addObject(v, x, y); } public MyWorld() { super(1177, 768, 1); for(int i=0; i<15; i++) { this.pridejVosu(); } }
danpost danpost

2019/10/26

#
Now move the for loop into its own method so you call it later from act method. Remove your new discussion thread. Deal with issues here.
You need to login to post a reply.