0
\$\begingroup\$

I'm working on a multiplayer game in Libgdx and want to display the scores of say, the top 10 players on the map. The player should be able to checking the scores at any point during the game and return to the game screen (with themselves in the same location they were at earlier), much like pressing Tab during a game of Counter Strike displays the scores.

Changing the screen to the score screen is simple enough using setscreen, but how can I return to the previous view without calling a setscreen on the game screen and rendering everything all over again?

\$\endgroup\$
  • 1
    \$\begingroup\$ There's probably no real way around that (note that I've never used libdgx so far). You'll typically have to redraw everything, unless you store the output in a render texture, but that wouldn't make any sense here IMO. Things like that are typically organized using a finite state machine, possibly in combination with a stack. Whatever is on top of your stack is updated/rendered. To go back to a previous screen, you just pop the top. \$\endgroup\$ – Mario Aug 9 '14 at 13:28
  • \$\begingroup\$ What is setScreen? Is that a libGDX function or your own function? \$\endgroup\$ – ashes999 Aug 9 '14 at 23:58
  • \$\begingroup\$ setScreen is a libgdx function used to change between screens. \$\endgroup\$ – dreadnought303 Aug 10 '14 at 14:16
0
\$\begingroup\$

Then make something like:

enum gameState = { PLAYING = 0, MAINMENU = 1, SCOREBOARD = 2, ... }

if(Player.action = PLAYING)
{
    ... do stuff ...
}
else if(Player.action = MAINMENU)
{
    ... do stuff ...
}
else if(Player.action = SCOREBOARD)
{
    ... do stuff ...
}

And about the rendering. It's hard to get around that.

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ Rather than comparing the value of Player.action you're assigning it. Plus I'd use switch() rather than multiple instances of if() even if it's just for readability. \$\endgroup\$ – Mario Aug 9 '14 at 13:48
  • \$\begingroup\$ Well, you could do switch. But the point is. You could give the player an INT action. I do it this way. And it works great. \$\endgroup\$ – ADG Developing Aug 9 '14 at 14:07
0
\$\begingroup\$

you have to create some table, whatever. that will be displayed on the current screen.

the values is the question important here. You have to call from where? got it?

if you saved the values on SQLite you can make a method that load the top scores.

you can read something about multiple input processors to alternate inputs when the user

click on score button (active scoreinputprocessor) and reactive gameinputprocessor when close score.

i did it just like this. i did got nice results.

REFERENCE:

Ok man, the files that you have to read to learn and use your creativity:

Multiple processors: InputMultiplexer

Table: Table Layout

EXAMPLE

Example

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ This doesn't seem to really address the question at all. \$\endgroup\$ – user1430 Aug 10 '14 at 17:41
  • 1
    \$\begingroup\$ On the contrary, this is probably the most appropriate answer for what the OP wants, especially in libGDX. Using a scene2d-ui Table will allow an overlay on top of the current screen without having to perform a setScreen(). Hence, the state of the game, including all the elements can remain while the score overlay is painted over the screen. The use of the multiplexer will enable touches to be sent to the score overlay without affecting the game underneath. Upon closing the overlay, the game can be resumed as per normal by in registering the overlay as an input processor. \$\endgroup\$ – midasmax Aug 10 '14 at 17:59
  • \$\begingroup\$ Perhaps, but I don't think this answer explains, to the asker, what actually needs to be done in a useful and coherent fashion. Your explanation is much better -- perhaps you should post it as an answer or submit a clarifying edit. \$\endgroup\$ – user1430 Aug 10 '14 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.