HI there,
my code doesn't behave the way I want it to...
I created 2 buttons which change the ScoreToWin like this:
STW.STW = STW.STW + 1
and
STW.STW = STW.STW -1
the class STW(score to win):
it doesn't change the Image of the class STW...
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class STW extends Buttons
{
GreenfootImage stw1 = new GreenfootImage("stw1.png");
GreenfootImage stw2 = new GreenfootImage("stw2.png");
GreenfootImage stw3 = new GreenfootImage("stw3.png");
GreenfootImage stw4 = new GreenfootImage("stw4.png");
GreenfootImage stw5 = new GreenfootImage("stw5.png");
GreenfootImage stw;
static int STW = 3;
public STW()
{
setImage(stw);
}
/**
* Act - do whatever the STW wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
changeSTW();
}
public void changeSTW()
{
switch (STW)
{
case 1: stw = stw1;
break;
case 2: stw = stw2;
break;
case 3: stw = stw3;
break;
case 4: stw = stw4;
break;
case 5: stw = stw5;
break;
default: stw = stw3;
break;
}
}
}