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

2016/11/28

Pause a game.

LimeLava LimeLava

2016/11/28

#
Is there a way that I could make the game pause for a second or two after something happens so that the player has a moment to realize what is happening between level changes.
fejfo fejfo

2016/11/28

#
yes there are multiple ways. The easiest is to have an act counter count up and start doing things after it has reached 100 or so like this:
byte actsPassed = 0;
public void act() {
   if(actsPassed <= 100) {
       actsPassed++;
   }else {
      //insert normal act code here
   }
}
Super_Hippo Super_Hippo

2016/11/28

#
If you want the whole game to pause, you can just use (with some number there):
Greenfoot.delay(100);
danpost danpost

2016/11/28

#
Since absolutely nothing will be happening during that short time, the following line should be sufficient:
Greenfoot.delay(100);
Super_Hippo Super_Hippo

2016/11/28

#
Wow, we even used the same number ;)
danpost danpost

2016/11/28

#
Super_Hippo wrote...
Wow, we even used the same number ;)
I think we both got it from the code fejfo gave.
LimeLava LimeLava

2016/11/29

#
Is there any way to pause all of the objects in the world from the world subclass or do I need to go to each class and make it check for something to happen?
danpost danpost

2016/11/29

#
LimeLava wrote...
Is there any way to pause all of the objects in the world from the world subclass or do I need to go to each class and make it check for something to happen?
You can use the 'Greenfoot.delay' method from any class. Is there some animation or something that is to happen while the world itself is "paused"? or do you just want a complete standstill for the delay time?
LimeLava LimeLava

2016/11/30

#
So i have some text in the corner of the screen that shows the level and I want it to pause everything for a few seconds when it reaches a different level.
You need to login to post a reply.