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

2021/1/23

Thread.sleep() causing problems

FirewolfTheBrave FirewolfTheBrave

2021/1/23

#
I have the method endLevel() in my World subclass which is called whenever the player clears the battle map:
1
2
3
4
5
6
7
8
9
10
11
12
public void endLevel()
{
        this.player.levelUp();
        try {Thread.sleep(3000);}
        catch (InterruptedException e) {}
        if (this.player.level <= 5)
        {
            this.state = TAVERN;
            constructTavern();
        }
        else finishGame();
}
Now, the method levelUp() includes a call to the message() method which I've tested many times and it always worked flawlessly. However, in this context, I can only see the cleared battle map for those three seconds, not the level up message. I know that the call to levelUp() is successful because the character starts the next level with updated HP and abilities, it's just the graphics that aren't updating. What am I doing wrong?
danpost danpost

2021/1/23

#
Try "repaint();" after line 3.
FirewolfTheBrave FirewolfTheBrave

2021/1/24

#
Thank you so much!
You need to login to post a reply.