How do I make a Game Main Menu?

I already have a game… but how do I create a menu in start just like
START and EXIT

Easiest way may be to grab Lemur and go from there.

An example game that sets up a menu (among other things):

But really if you just want a couple of buttons in a panel then this is really easy in Lemur:

Container myWindow = new Container();
myWindow.addChild(new Button("Start")).addClickCommands(new Comment<Button> {
        public void execute( Button b ) {
            startTheGame();
        }
    });
myWindow.addChild(new Button("Exit")).addClickCommands(new Comment<Button> {
        public void execute( Button b ) {
            stop();
        }
    });

myWindow.setLocalTranslation(200, 400, 0);
guiNode.attachChild(myWindow);

Possibly even simpler if you use actions and ActionButton because then you can just call methods on your class directly.

1 Like

What happened?

You need to add slf4j jar to your project library
Did you read lemur dependencies ??
see https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Getting-Started#required-dependencies

sorry

1 Like

Or you can go through the difficult, painful process of learning Nifty.
https://jmonkeyengine.github.io/wiki/jme3/advanced/nifty_gui.html
It’s not worth it for a small program though.

why?

You must be using the now-ancient JME 3.0. If so then you need to use an older version of Lemur because the class signatures changed for Application between 3.0 and 3.1.

Lemur 1.7.1 was the last version to support 3.0.

OMG I dunno what happen

When you post exceptions, please include the stack trace.

image

hi, i’m a beginner. I have follow the tutorial but it’s not working, so i have an error “Uncaught exception thrown in Thread[jME3 Main,5,main]
NoClassDefFoundError: com/google/common/io/Resources”

what should i do? thanks

You need to add the Guava.jar library to your project, which is one of lemur’s dependencies

https://github.com/jMonkeyEngine-Contributions/Lemur/wiki/Getting-Started#required-dependencies

3 Likes

thanks, its working :smile:

2 Likes

Glad to hear, and welcome to the jme community! :slightly_smiling_face:

1 Like