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

2019/2/21

I want to add objects i just removed

R0b1n R0b1n

2019/2/21

#
I made a code that if i touch a certain block all lava in my level gets removed. that works and all but then if i stop touching that block i want my lava to come back in the level so you cant get passed
    public void Button()
    {
        if(canSee(FloorButton.class))
        {
            World world = getWorld();
            world.removeObjects(world.getObjects(Lava.class));
        }
        else { 
            getOneObjectAtOffset(125,425,Lava.class);
        }
    }
danpost danpost

2019/2/21

#
R0b1n wrote...
I made a code that if i touch a certain block all lava in my level gets removed. that works and all but then if i stop touching that block i want my lava to come back in the level so you cant get passed << Code Omitted >>
Add a method in your world class that adds all Lava objects into your world. Move all code pertaining to Lava objects in your prepare method into this new method while maintaining their order. Call the method from the prepare method and from the above to add lava back into the world.
You need to login to post a reply.