This site requires JavaScript, please enable it in your browser!
Greenfoot back
b321234
b321234 wrote ...

2011/12/23

Why doesn't the actor change its image?

b321234 b321234

2011/12/23

#
So I'm still working on that game, and I'm adding the level system. Here's the code: It's in the ZombieWorld class
Zombie zombie = new Zombie();
...(Constructor) ...(Prepare)
public void act(){
        boolean gameLevelUpTo4 = gameLevelUpTo4();
        if(gameLevelUpTo4){
            gameLevel=4;
            setBackground("rivets4.jpg");
            zombie.setImage("zombie-4.png");
            zombie.addZombieLevel();
            player.grenadeNum=0;
        }
    }
So I have the zombie.setImage("zombie-4.png"); here. But obviously it just doesn't change the image when I reach level 4. What's with that? Is it like... the Zombie zombie = new Zombie?? If so, how should I change the code? Thanks!!
Builderboy2005 Builderboy2005

2011/12/23

#
What goes on inside addZombieLevel() ?
b321234 b321234

2011/12/23

#
@Builderboy2005 In that method is
 private int level = 1;
  public void addZombieLevel(){
        level++;
    }
public void act() 
    {
        int moveX = Greenfoot.getRandomNumber(30)-15;
        setLocation(getX()+moveX, getY()+level*2);
}
and it's doesnt increase its speed. i dont know what the problem is...
danpost danpost

2011/12/23

#
What is in your gameLevelUpto4() method? and where is gameLevel changed? and do you have private int gameLevel = 1; with Zombie zombie = new Zombie();? On this last question, I would think so, or you would get an error on compilation.
b321234 b321234

2011/12/25

#
@danpost @Builderboy2005, forget it I don't feel like changing the pic now, thank you so much for helping me with my game, merry christmas ;)
b321234 b321234

2011/12/25

#
danpost wrote...
What is in your gameLevelUpto4() method? and where is gameLevel changed? and do you have private int gameLevel = 1; with Zombie zombie = new Zombie();? On this last question, I would think so, or you would get an error on compilation.
Oh I had a addZombieLevel method to deal with it haha
You need to login to post a reply.