Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (767)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (854)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Start, Pause and Game Over screens  (Read 17089 times)
0 Members and 1 Guest are viewing this topic.
Offline kutucuk

Senior Devvie

Medals: 5
Exp: 3 years

« Posted 2014-03-21 21:20:15 »

I am trying to make a platform game using Box2D and LibGDX. I wonder how you handle Pause, Start and Game Over screens.

By Start screen, I mean this: When the game begins, I start it as paused, so the player can be ready for moving the character. I do this by rendering a black image with alpha= 0.5f, and a Scene2D label "Touch the screen to begin".
I don't have a Pause screen yet lol.
Game Over screen is also a black image with 0.5 alpha value and a label saying "Game Over". I haven't put any buttons for restart or go to menu, but I am planning to do.

But like I said, I wonder how you handle these kind of screens. Do you make a new class which extends Screen (those who are familiar with LibGDX should understand what I mean Smiley) and show that when the player pauses the game or when the game is over?

What do you do with these screens? How do you handle this?
Offline atombrot
« Reply #1 - Posted 2014-03-22 18:28:05 »

I'm using the Screen interface... If your main class derives from the Game class, you can call setScreen and set the game screen.

Here is an example from our LD28 entry.

The main class:
Implementation of a screen:

Offline Jimmt
« League of Dukes »

JGO Kernel

Medals: 167
Projects: 5
Exp: 6 years

« Reply #2 - Posted 2014-03-22 21:46:21 »

I use a base screen class that implements Screen, and then I have my other screens extend that base class. As a result I have the libgdx Screen functionality but can also put my own stuff into the base screen class.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kutucuk

Senior Devvie

Medals: 5
Exp: 3 years

« Reply #3 - Posted 2014-03-23 18:34:12 »

Thanks for the replies guys.
So, you have another screen for these stuff and you just take the player to that screen when the game stops or it's over.

I wonder, doesn't that affect the gameplay? For instance, my game turned out to be an infinite jumper now (lol). So, that means if the player falls, the game should be over. And that means, the player should be able to see what's going to happen when the game begins so that he can have time to react (for example, press "left" key to prevent the player from falling down and the game from an instant end. Ugh... I mean, if I have a Pause screen, the player won't be able to see what's next.

Another concern for me would be preserving the game state, which I have never tried to do. The whole idea of pausing the game is to be able to start from the exact spot you left. I don't know how to do that. Any guides for this?  

I'll have to get the whole project and play with it, compile it etc. I hope that is okay for you. Of course I'm not gonna distribute it. I won't use the code, but I might take inspiration from it, as the whole point of me looking at that code is to learn how you guys do it Smiley
Offline atombrot
« Reply #4 - Posted 2014-03-24 15:48:38 »

i usually have a screen implementation for the main menu and one for the gameplay.  I have set up a scene2d stage in my gameplay screen for the ui. If I wanted to implement a pause screen, I add an additional UI element as overlay and make it small or translucent.
To pause the game you simply have to stop updating the game logic, when you enter pause mode. When you continue the game you start updating again.

You don't need to do much to persist the state, if you just wan't to implement pause and play. If you want the ability the exit the game and reopen and continue, then you need to write the game state to disk.

You can use my code to understand what's going on, but you have to keep in mind that this "game" was hacked in 3 days and I'm still getting to know libgdx, so it is not exactly a prime example of a libgdx project Wink
Offline kutucuk

Senior Devvie

Medals: 5
Exp: 3 years

« Reply #5 - Posted 2014-03-24 19:15:15 »

Well, I'll try to implement something for this, but let's see how it goes.

I'm not looking for a perfect or professional or right way to do these screens, so it's okay atombrot. I'll download the source, compile it and see how you did that.

But still I'm open to alternative implementations if anyone does this in some other way.
Offline achap1989

Senior Newbie

Medals: 1

« Reply #6 - Posted 2014-04-23 22:05:36 »

Currently in my rpg engine I have a base that uses a gamestate manager and will update and draw whatever state is currently selected.  Feel free to check it out and use it.
My project

Pages: [1]
  ignore  |  Print  

EgonOlsen (1328 views)
2018-06-10 19:43:48

EgonOlsen (1204 views)
2018-06-10 19:43:44

EgonOlsen (929 views)
2018-06-10 19:43:20

DesertCoockie (1330 views)
2018-05-13 18:23:11

nelsongames (1110 views)
2018-04-24 18:15:36

nelsongames (1359 views)
2018-04-24 18:14:32

ivj94 (2093 views)
2018-03-24 14:47:39

ivj94 (1251 views)
2018-03-24 14:46:31

ivj94 (2249 views)
2018-03-24 14:43:53

Solater (803 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!