Creating a menu in a basic 2d game
Hey so as you may have seen, I am making a pong remake for a Java course. I would like to add a menu functionality to my game. All I would want is Play, Scoreboard, and Quit buttons. I would like it to display when the game is brought up, and maybe when esc key is hit. I'm not sure how to go about doing this. In theory, I would like to be able to draw this once, and have it sitting somewhere in memory and when it is needed, to just pull it up. I feel like that would be more efficient than drawing it each time it is needed. Seems wasteful considering it will be the same each time. I am using AWT and Swing to handle graphics and this program. I have a little bit of experience using buttons in java, but nothing like what I'm wanting
Re: Creating a menu in a basic 2d game
Why not create a JMenu?
Quote:
Originally Posted by
ResidentBiscuit
I am using AWT and Swing
Mixing AWT and Swing is a bad idea.
Re: Creating a menu in a basic 2d game
JMenu is all I have experience with, with what ive done it only really makes menu strips right? I'm looking for like a middle of the screen type menu, without visible "buttons". Imagine old school Doom games. Why is mixing the two a bad idea?
Re: Creating a menu in a basic 2d game
Do you want the menu to appear over the top of the game (which pauses it)? Use a dialog box. Do you want the menu to appear above/below/beside the game. Then create another JPanel.
Swing uses lightweight components and AWT does not. If you want more information I'm sure Google will return plenty of articles on the subject.
Re: Creating a menu in a basic 2d game
I'm not sure what you mean with the directions. But I think I want on top of? Is there no way to place these buttons in the same frame?
Re: Creating a menu in a basic 2d game
Quote:
Originally Posted by
ResidentBiscuit
Is there no way to place these buttons in the same frame?
Yes that would be option 2 above. Use a second panel which holds the menu options and place it side-by-side to the panel which holds the game.