how to make objects disappear after being spawned.

14 views
Skip to first unread message

desti...@gmail.com

unread,
Apr 21, 2015, 3:06:01 PM4/21/15
to greenfoot-dis...@googlegroups.com
ex. i make projectiles how to make them disappear after being spawned and not stay in the world.

spar...@gmail.com

unread,
Apr 21, 2015, 3:26:31 PM4/21/15
to greenfoot-dis...@googlegroups.com
For example, the instance I am trying to remove is called "Foe".

Actor foe;
        foe = getOneObjectAtOffset (0,0,Foe.class);
    if (foe !=null)
    {
        World world;
        world = getWorld();
        world.removeObject(foe);



Like I asked in another question, you must declare it before you use the "world.removeObject(foe);", which seems pretty silly to me.

Wen Bei

unread,
Apr 21, 2015, 3:28:22 PM4/21/15
to greenfoot-dis...@googlegroups.com
Use removeObject(this);
Reply all
Reply to author
Forward
0 new messages