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

2016/5/18

Spawn new items after this items disappear

Vojin Vojin

2016/5/18

#
I do not speak English very well, but I think you will understand me. I have one probelm. This is my first video game making. So my problem is that i can`t spawn new object when this object which on background disappear. I need your help. Can someone please send me code for that. Thanks :)
SPower SPower

2016/5/18

#
I'm assuming that at some point you do one of these things:
1
2
3
4
5
6
7
8
// 1:
removeObject(object);
 
// 2:
getWorld().removeObject(object);
 
// 3:
getWorld().removeObject(this);
You could simply add a line before doing this:
1
2
3
4
5
// if you do the first of the three above, add:
addObject(new ...(), x, y);
 
// otherwise:
getWorld().addObject(new ...(), x,y);
It is important that if you use option 3, you add the new object before removing the object itself. because after it is removed, getWorld() will return null.
You need to login to post a reply.