-2

I'm making a 2d game with libgdx.

To be be clear in the question My code looks as follows:

public Class Game(){

      public void Mainloop{
         update();//to update some values
         render();//to render the values on the screen
      }


      public int showmessageOnthescreen(List<String> listOfChoice){

      }

    }

As you know the game loop don't stp rendering.

sometimmes showmessageOnthescreen will be called to ask the user to choose a String from a list of string.

My question is how can i ask the user to choose from the list.

Daahrien
  • 10,190
  • 6
  • 39
  • 71
user3521250
  • 115
  • 3
  • 14

1 Answers1

1

how can check if the method was called to put the message on the screen

Set some boolean the first time the method is called.

how can i return a value

By writing return someValue;.

how can i call the method from outside and in the same time the loop has to update and show the screen permanently

If your loop is looping, only things inside it will be executed.

So everything you want to call during the looping, put them inside the loop, or inside functions that are called in the loop.

For example, if you want to call showmessageOnthescreen only at specific times, then you probably need an if inside your loop, probably inside the update method:

if (messageNeedsToBeShown())
    showmessageOnthescreen();
Emil Laine
  • 41,598
  • 9
  • 101
  • 157
  • thank you zenith i had this idea but i was searching for better solution and idiom in game programming – user3521250 Mar 18 '15 at 17:05
  • You need to be more precise to get an answer that would help you. What is it you want to *actually* do? Please edit your question. – Emil Laine Mar 18 '15 at 17:20