I was making a simple Greenfoot game, and I have a spider that moves around with the WASD keys. It works for a small amount of time, and then the keystrokes do not do anything. I press the keys, but the spider stops moving. So i'm pretty sure it isn't a code problem. Does anyone know what's up?
public void act()
{
keyMove();
eat();
}
public void keyMove()
{
if (Greenfoot.isKeyDown("w"))
{
setLocation(getX(), getY()-5);
}
if (Greenfoot.isKeyDown("s"))
{
setLocation(getX(), getY() +5);
}
if (Greenfoot.isKeyDown("a"))
{
setLocation(getX() -5, getY());
}
if (Greenfoot.isKeyDown("d"))
{
setLocation(getX() +5, getY());
}
if (Greenfoot.isKeyDown("right"))
{
turn(10);
}
if (Greenfoot.isKeyDown("left"))
{
turn(-10);
}
}
public void eat()
{
if (isTouching(Lobster.class))
{
removeTouching(Lobster.class);
}
}
}

