hey peeps,
so i have a little problem. I want one of my actors to add an object (zandzak) if the upper neighbour is a water object. however it seems their is something wrong with my if statement because i can add an object everywhere hitting space... this is what my code looks like and i hope you can help
List kijkbuuren;
public void act()
{
kijkbuuren = getNeighbours(0,false, Watervloed.class);
if(Greenfoot.isKeyDown("left"))
{
setLocation(getX()-1,getY());
}
if(Greenfoot.isKeyDown("right"))
{
setLocation(getX()+1,getY());
}
if(Greenfoot.isKeyDown("up"))
{
setLocation(getX(),getY()-1);
}
if(Greenfoot.isKeyDown("down"))
{
setLocation(getX(),getY()+1);
}
if(kijkbuuren !=null && Greenfoot.isKeyDown("space"))
{
int x = getX();
int y = getY();
getWorld().addObject(new zandzak(),x,y);
}
}

