Creating an application without using SimpleApplication

Hi,



I’m relatively new to jMonkey but have worked myself through the tutorials and noticed that all of them use the SimpleApplication class. While this class is great and will probably initialize my application just fine, I’d like to write my own Application child class, for the sake of better understanding what’s going on behind the scenes and maybe to even have a greater influence on what my application is actually initializing (basically the SimpleApplication feels a bit like a crutch for me which I would rather avoid).



Now I have, of course, looked into what the SimpleApplication class actually does and “copied” those parts of it I felt where necessary for my simple application so that it will show a black screen and the statsView, initializing the graphics and audio renderer, setting several settings in the process and starting the application. Instead of showing the statsView, though, it just shows the black screen and nothing else.



Did I forget anything? Here’s the code I’ve been using for my CustomApplication class:



[java]

package mainPackage.main;



import com.jme3.app.Application;

import com.jme3.app.StatsView;

import com.jme3.renderer.queue.RenderQueue.Bucket;

import com.jme3.scene.Node;

import com.jme3.scene.Spatial.CullHint;

import com.jme3.system.AppSettings;



public class CustomApplication extends Application

{

private Node root = new Node(“rootNode”);

private Node guiRoot = new Node(“guiRoot”);



public CustomApplication()

{

super();

AppSettings settings = new AppSettings(true);



settings.setFullscreen(false);

settings.setWidth(800);

settings.setHeight(600);

settings.setUseInput(true);

settings.setTitle(“TestApplication”);

settings.setRenderer(AppSettings.JOGL);

settings.setAudioRenderer(AppSettings.LWJGL_OPENAL);

this.setSettings(settings);

}



@Override

public void initialize()

{

super.initialize();



guiRoot.setQueueBucket(Bucket.Gui);

guiRoot.setCullHint(CullHint.Never);



guiRoot.attachChild(new StatsView(“statsView”, assetManager, renderer.getStatistics()));



this.viewPort.attachScene(root);

this.guiViewPort.attachScene(guiRoot);

}



public void guiHandling()

{



}



public void sceneHandling()

{



}



public Node getRoot()

{

return root;

}



public Node getGuiRoot()

{

return guiRoot;

}

}

[/java]

You will understand SimpleApplication after a while, no need to create your own, you wouldn’t want to create your own AnimationControl to see how it works, would you? :slight_smile: Just look at the source code (right-click->navigate to source). Even Mythruna uses the “SimpleApplication” and its not really meant to be replaced by anything else. Maybe we shouldn’t call it SimpleApplication, people seem to be irritated by that.

Thanks for replying,



for now I think I will use SimpleApplication, but it’s not only about understanding it, but also about control. I just want to create a very simple 2D Adventure type game (like monkey island 1 or 2) and therefore don’t need several stuff SimpleApplication might initialize.



Nonetheless, because it is somehow an ambition of mine, I would like to be able to create my own version of a SimpleApplication class. Call it curiosity or ambition but to actually work with something you should be able to handle most of it. It’s probably just a thing of mine, but I come from a rather technical background (Dipl. in Computer engineering) and thus have a desire to research every detail as much as I can.

I would like to create my own JNI libraries and stuff, of course, but I think the jMonkeyEngine handles that just fine and I don’t actually need to do that (just now). But still, to know why SimpleApplication works and my CustomApplication doesn’t would give me some kind of satisfaction. :slight_smile:



So if you have any suggestion, whatsoever, as to why my version doesn’t work, I would be most grateful if you (or anyone) could help me.



TL;DR: I don’t want to just use it, I want to understand…get some degree of expertise in all this, if you know what I mean.

You don’t gain any additional control, the control logic of your game should be in AppStates and Spatial Controls. You application stub does almost nothing of what SimpleApplication does, did you really look at the source of SimpleApplication? The statemanager for example is called in SimpleApplication, also all updateGeometricState() etc. calls are made there. All of that is missing in your application.

Ah, there I thought the update() function of the Application class would take care of that. How stupid of me, as there would be no reason for SimpleApplication to do just that then. Also I was apparently oblivious to AppStates, how embarrassing. Thanks for the advice! I will look into it. :smiley:

I had a similar approch in my game when I decided to make my own Application class.

Instead of creating it from scratch as you did I copied everything from SimpleApplication and then deleted what I didn’t want :slight_smile:

WASD said:
Instead of creating it from scratch as you did I copied everything from SimpleApplication and then deleted what I didn't want :)

Which in the end only was the flyCam I guess :P