I can't figure out how to make my background change colors every ten seconds, if someone could help me that would be amazing
private int bgTimer;
public void act() {
if (bgTimer == 0) changeBgColor(); // timer check
bgTimer = ++bgTimer%600; // timer tick
}Color[] bgColors = new Color[] { Color.YELLOW, Color.GREEN, Color.BLUE, Color.RED };
int bgColorNum; // array pointer
private void changeBgColor() {
// create color image
GreenfootImage image = new GreenfootImage(getWidth(), getHeight());
image.setColor(bgColors[bgColorNum]);
bgColorNum = (bgColorNum+1)%bgColors.length;
image.fill();
image.setTransparency(80); // change or remove as needed
// change background
getBackground().setColor(Color.WHITE);
getBackground().fill();
getBackground().drawImage(image, 0, 0);
}getBackground().setColor(bgColors[bgColorNum]); bgColorNum = (bgColorNum+1)%bgColors.length; getBackground().fill();