I'm trying to add an object on command to act as a shield, but after lots of trial and error, I couldn't get it.
Here's my code:
Actor Wall2;
Wall2 = getOneObjectAtOffset(0,0,Wall2.class);
if(Greenfoot.isKeyDown("w"))
{
World area;
area = getWorld();
area.addObject(Wall2,400,200);
}
if(Greenfoot.isKeyDown("s"))
{
World area;
area = getWorld();
getWorld().removeObjects(getWorld().getObjects(Wall2.class));
}
