• Post Reply Bookmark Topic Watch Topic
  • New Topic

Splash screen for my game  RSS feed

 
Nolan Bisschoff
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
First post here
I have been a member of JavaRacnh for 2 years (when I did my SCJA exam) but never posted before.

I am writing a little game and am really struggling with something and hope someone here might be able to help.

So basically, I am writing a little game and when it load it needs to display a "splash screen" which shows the game name and then has a button that you click to enter the game. I have managed to make the screen and display it, but while it is showing the game loop keeps running in the background. SO my question is "How do i display the screen and have the program wait until someone clicks enter before the game loop kicks off?"

Code:
I have a ScreenLayout class which houses the welcomScreen() method as well as all the other display methods and the listeners for the mouse click on the enter button. Code of loop below:



So what happens is screenLayout.welcome() displays the welcome screen but then i can see "Game running" being printed the whole time in the background, how do I make sure that the program only continues once they click the Enter button on the welcome screen?

Thanks,
Nolan.
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a ScreenLayout class which houses the welcomScreen() method


You also need another method like "startGame". Then in the ActionListener for the button you invoke that method.
 
Campbell Ritchie
Marshal
Posts: 55793
164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

A few people have signed in nearly ten years before ever posting anything.
 
Nolan Bisschoff
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob!!

I modified the design a bit and now call the runGame() method from the action listener and it works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!