Standard Game Update

I went through the tutorials on starting to use Standard Game. My problem is that I don't know how to make an update method. Is there a way to override it, or is the game loop my responsibility?

With standardgame you have to create GameStates, where logic and render methods are in.

After creating a GameState, you can add it to GameStateManager.getInstance(), it will be updated and rendered.



If you create your own GameState by extending BasicGameState, that superclass already has an update method that will update the geometric state: you don't have to explicitly implement everything yourself.  However, if there is anything else you want to do specifically in your sub-class every time through the loop, you can override the update method (just follow the signature). 

I did what mjsimpson said, and I got a NullPointerException. I extended BasicGameState, and changed the update method to update my input too. Here is my source for the extension:

public class BasicGameState2 extends BasicGameState {
    boolean printed = false;
    BasicGameState2(String name) {
    public void update(float tpf) {
        try {
        } catch(Exception e) {
            if (printed==false) {
                printed = true;

And here is the NPC:

        at demoapp.BasicGameState2.update(

Apparently it happened while it was updating. Did I type the method wrong? All I did in the Main file was declare input like this:

public static InputHandler input;

Please, any help would be appreciated, I want to get my game going somewhere.

Assuming the null pointer exception was on the line calling Main.input.update(tpf), the issue is that the "input" member has yet to be initialized.  You have created the variable, but not given it a value at this point ( input = new InputHandler(…) ).

You could add some check to see if it is null before you use it, or only enable that GameState after you've done all of your initialization that it relies on.

Oh. Lol. I'm an idiot. I never created it in the first place. :smiley: