J-Monkey subclass
        Posted  
        
            by 
                user2971104
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user2971104
        
        
        
        Published on 2013-11-09T03:50:44Z
        Indexed on 
            2013/11/09
            3:53 UTC
        
        
        Read the original article
        Hit count: 293
        
java
|jmonkeyengine
I'm new in java and J-monkey and I'm trying to make a java game so for the Menu I have made a enum so I can Switch between any of my State but I want to keep the main file shorter so it can be easily to read so I'm making subclass the problem is that when run the game it give me an error that say "Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main] NullPointerException" I think this problem has to be something whit the pipeline Here is the code of my main file:
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.font.BitmapText;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Spatial;
import com.jme3.scene.Geometry;
import com.jme3.input.*;
import com.jme3.input.controls.*;
public class Main extends SimpleApplication {
//GameStates
enum GameState{Logo, Menu, Playing, Option};
GameState gameState = GameState.Logo;
//Class Variables
Logo logo;
public Main() {
logo = new Logo();
}
public static void main(String[] args) {
    Main app = new Main();
    app.start();
}
public static void logo(String[] args) {
    Logo app = new Logo();
    app.start();
}
@Override
public void simpleInitApp() {
    //Load
    flyCam.setMoveSpeed(20);
    if(gameState == GameState.Logo){
        logo.simpleInitApp();
    }
}
@Override
public void simpleUpdate(float tpf) {
}
@Override
public void simpleRender(RenderManager rm) {
    //TODO: add render code
    //Load
    if(gameState == GameState.Logo)
    {
    }
}
}
And here is my Logo subclass:
package mygame;
    import com.jme3.app.SimpleApplication;
    import com.jme3.renderer.RenderManager;
    import com.jme3.scene.Spatial;
    public class Logo extends SimpleApplication {
    @Override
    public void simpleInitApp() {
    Spatial Logo_Model = assetManager.loadModel("Models/Teapot/Logo.obj");
    rootNode.attachChild(Logo_Model);
    }
    public void simpleRender(RenderManager rm) {
    //Load
    }
    }
        © Stack Overflow or respective owner