Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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 3610 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.

Edit:
Here is an example from our LD28 entry.

The main class: https://github.com/tomvangreen/ch.digitalmeat.ld28/blob/master/ld28/src/ch/digitalmeat/ld28/ConcertSmugglers.java
Implementation of a screen: https://github.com/tomvangreen/ch.digitalmeat.ld28/blob/master/ld28/src/ch/digitalmeat/ld28/RulesScreen.java

Online Jimmt
« League of Dukes »

JGO Kernel


Medals: 139
Projects: 4
Exp: 3 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?  

EDIT:
@atombrot
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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (28 views)
2014-12-15 09:26:44

Mr.CodeIt (19 views)
2014-12-14 19:50:38

BurntPizza (37 views)
2014-12-09 22:41:13

BurntPizza (72 views)
2014-12-08 04:46:31

JscottyBieshaar (34 views)
2014-12-05 12:39:02

SHC (46 views)
2014-12-03 16:27:13

CopyableCougar4 (42 views)
2014-11-29 21:32:03

toopeicgaming1999 (110 views)
2014-11-26 15:22:04

toopeicgaming1999 (96 views)
2014-11-26 15:20:36

toopeicgaming1999 (29 views)
2014-11-26 15:20:08
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!