public int score = 0;
public void act()
{
int counter = 0;
counter += 1;
int speed = 3;
if (Greenfoot.isKeyDown("Up")) {
setLocation(getX(), getY() - speed);
}
if (Greenfoot.isKeyDown("Down")) {
setLocation(getX(), getY() + speed);
}
if (Greenfoot.isKeyDown("Left")) {
setLocation(getX() - speed, getY());
}
if (Greenfoot.isKeyDown("Right")) {
setLocation(getX() + speed, getY());
}
if (isTouching(Point.class))
{
score = score + 1;
System.out.println(score);
}
}
}
This is my actor class for my actor that requires contact with a point to add 1 to the score. But I want it to only add 1 point instead of it rapidly increasing the score. Anyone know how to fix?
