When should you suse/extendSimpleApplication and when to use AbstactAppstate

I am trying to run this abstract app state class but it saying that it does not have a main method.
So every class that is not the main method/class should extend AbstactAppstate? I am a bit confused.

Also not every class should be the main class and extend simple application?
How do I run this abstract app state class without

public static void main(String[] args) {
example app = new example1();
app.start();

Or do you put that in and do you extend AbstractApp class even if you dont want app states I’m confused. Sorry if this is a newbie questionI

I’m folllowing the Nifty Gui tuts and instead of using xml (Because It did not work last time) I am using Java so for the screen class I extend the AbstrctAppState instead of Simple Application because I heard you only extend Simple Application for the Main class. For which the Main class contains the actually ‘game’ (eg moving the player the the assets etc) or I’m I missing something or doing something wrong?

I think I figured it out I looked at the BookSamples. Thanks tho

Yep I think i’m really getting it

Think of it this way: your game has one class that extends SimpleApplication.
That class initializes your game and via SimpleApplication, takes care of some of the work for you, and provides you the main loop of the application.
Part of the initialization is attaching AppStates that correspond to the main bricks (ideally quite self-sufficient bricks) of your application, such as your vehicle, circuit, speedometer and such stuff.
The welcome user interface should be an appState too.

AppStates are totally optional though… you can make a game using jme without using them, but they are a beautiful pattern that will help you reduce dependencies between your bricks. Try them and you’ll never come back.

In case you didn’t know, an abstract class in java can’t be instanciated. You need to have a class extend it and implement it’s abstract methods there. Then instantiate from that extension class.

Personaly, I extend from BaseAppState (https://code.google.com/p/jmonkeyplatform-contributions/source/browse/trunk/Lemur/src/com/simsilica/lemur/event/BaseAppState.java?r=972) instead, because it provides some inner logic such as calling the disable method before detaching and such stuff.

Everybody here will tell you that you should spend a couple days getting the basics of java right before going for a 3D game because you (and anybody else in such a situation) will go nuts otherwise. Abstract classes, interfaces, constructors are notions you need to be comfortable with.

1 Like