I made a counter to represent the number of balls in the world, which starts at 5. When they collide, the counter goes down. When they are added through a mouse click, the counter goes up. Right now, my counter is stuck at 5. Is there a problem in the counter class or the ball class?
public class Counter extends Actor { private int target; private GreenfootImage background; private static final Color TRANSPARENT = new Color (0,0,0,0); /** * Counter - constructor, initializes beginning variables and counter image to display zero */ public Counter() { target = 5; background = getImage(); updateImage(); } /** * updateImage - updates the image on the screen to show the current counter value. */ public void updateImage() { GreenfootImage image = new GreenfootImage(background); GreenfootImage text = new GreenfootImage("" + target, 22, Color.BLACK, TRANSPARENT); image.drawImage(text, (image.getWidth() - text.getWidth())/2, (image.getHeight() - text.getHeight())/2); setImage(image); } /** * Add - adds a new value to the current counter value */ public void add(int score) { target = target + score; updateImage(); } }