I'm now stuck in creating a game which is similar to Invaders. There's a class Wall which should change its Image when being touched be class Lazer; howecver, it does not work and I don't know why. That's my code.
I would be incredibly grateful for any help with this question.
public class Wall extends Defence
{
static int num; //how many objects were hit
public static int getWall(){
return num;
}
public void act(){
if (isTouching(Lazer.class)){
for (int i=1; i<=32; i++){
num=i;
}
} else {
num=32;
}
if (num == 32){
//GreenfootImage wallImage = new GreenfootImage("Wall1.png");
setImage("Wall1.png");
} else if (num < 32){
// GreenfootImage wallImage = new GreenfootImage("Wall" + num + ".png");
setImage("Wall" + num + ".png");
}
}
}