How to create a splash screen

I am starting to use jMonkeyEngine for little games and projects and I wanted to add a couple of splash screens while my app is loading. I am using Lemur, right now, but I’ll accept also a “pure” jme-based solution.
My idea is to display the jMonkeyEngine logo for 2-3 seconds (with fade-in and fade-out animations, but that is another layer of complexity for later), then maybe “A game by Ledmington” also for 2-3 seconds and then the main menu of the app.
The only help I could find online is this post which does not work, maybe because the behavior of jme has changed from 2011.

That thread is talking about a splash screen before the app is really even open. Which I think is different than what you are talking about.

If you mean just some nice splashes once the JME window is already open, if it were me then I would use Lemur for that. It already has the tween animations to do fade in/out, etc… It’s even possible to create an Effect to do this but that’s probably overkill in this case.

Something like:

Panel splash = new Panel();
splash.setBackground(new IconComponent("yourimage.png"));
GuiGlobals globals = GuiGlobals.getInstance();

    PanelTweens.fade(splash, 0f, 1f, 1.5),
    PanelTweens.fade(splash, 1f, 0f, 1.5),
    Tweens.callMethod(splash, "removeFromParent")

Note that “Tweens” in this case is Lemur’s Tweens class and not JME’s.

It is telling me that The method show(Panel) is undefined for the type PopupState. Am I missing something?

Yes, you need to look at the javadoc and interpret my from memory ramblings into actual code.

Edit: I know that the above looked like actual code… but I did not test it, did not look at javadoc, etc… it’s all from memory so might be best considered as pseudocode.

Desktop 2022.10.08 -
How do I make the image adaptive full screen?

I created an open-source JMonkeyEngine loading screen that works with or without Lemur. It displays an animated monkey and “Powered by JMonkeyEngine.”

Here’s the repository: GitHub - stephengold/JmePower: Java libray to promote the jMonkeyEngine game engine

In case you want an example app, the JmePower loading screen is used in the “MavDemo1” application in the “More Advanced Vehicles” project: GitHub - stephengold/jme-vehicles: A tech demo and library for jMonkeyEngine vehicles


Thank you very much @sgold, I tried your library and it’s really nice but at the same time too comfortable for someone wanting to learn like me.

@pspeed, I messed around with your code and the documentation and my current solution, which is still not working, is this one:

final Panel splash = new Panel();
splash.setBackground(new QuadBackgroundComponent(ColorRGBA.Red));
final Container container = new Container();
container.setLayout(new BorderLayout());
container.addChild(splash, BorderLayout.Position.Center);

I was trying to get to visualize a different background color to get a working code before moving on to the actual image but it still doesn’t work. Maybe I am taking the wrong approach: I am placing this code inside simpleInitApp method of my SimpleApplication.

1 Like

The problem with the code as you have it is that nothing has any size. So your container will by 0,0,0 in size and thus the splash will also be 0,0,0 in size.

Set the preferred size of the container to be the size of the screen.

Something like:
container.setPreferredSize(new Vector3f(cam.getWidth(), cam.getHeight(), 1));

Edit: earlier when I suggested the IconComponent it’s because the IconComponent will normally force the thing its in to be the size of the image in the IconComponent. It wasn’t going to be the size you wanted but would have displayed something if it worked.