So we are making a game, kind of like piano tiles. We made a counter and if you click on the block it adds 1 point, but if you click on the background the same thing happens. The code we used is:
This is in class counter.
public void act()
{
setImage(new GreenfootImage("Score : " + score, 24, Color.BLACK, Color.WHITE));
if(Greenfoot.mouseClicked(null)){
addScore();
}
}
How can we avoid this problem.