I think it would be easy enough to just use world class field for the color array. Then, the color scheme could be coded as an array of paired int values representing indecis of that color array. Something like this:
public class MyWorld extends World
{
private static final Color[] colors =
{
Color.WHITE;
Color.RED,
Color.YELLOW,
Color.BLUE,
Color.ORANGE,
Color.PINK,
Color.CYAN,
Color.MAGENTA,
Color.GREEN
};
private int[][] schemes =
{
{ 3, 2 }, // for level 1 (level value is 0)
{ 1, 4 }, // for level 2 (level value is 1)
};I am not even sure if you need that image class. All you really need is a static method in the same MyWorld class that takes the filename and uses the current level value to create the appropriate image and return it:
public static GreenfootImage getImage(String filename)
{
GreenfootImage image;
// build 'image'
return image;
}It can be called by any of your actor classes from their constructors:
public Rocket()
{
setImage(MyWorld.getImage("rocket.txt"));
}Line 3, the 'setImage' line, can also be coded elsewhere in the class to update the colors of the actor.