Problem with States

hello again, i try to create 2 states for my game but when any one  state is calling, the camera doesnt show any

thing,i paste the code for my gameState and my main class.

i appreciate your help

public class GuerraDeBolas extends SimplePhysicsGame {
   long initTime;
   long time;
   MenuState menu;
   boolean active=false;
   EstadoJuego jugando;
  
  
    protected void simpleInitGame() {
        GameStateManager.create();
        initTime = Calendar.getInstance().getTimeInMillis();
        menu =new MenuState();
      
        menu.setActive(true);
       GameStateManager.getInstance().attachChild(menu);
      
  
  }
    @Override
    public void simpleUpdate(){
        time = Calendar.getInstance().getTimeInMillis();
         System.out.println(activo);
        if (time-initTime>3000 && active==false){
            System.out.println("entro");
            menu.setActive(false);
            active=true;
            jugando=new EstadoJuego(cam);
            jugando.setActive(true);
              GameStateManager.getInstance().attachChild(jugando);
            System.out.println(tiempoActual);

        }
    if (active){
        jugando.simpleUpdate();
    }
    }
}



public class EstadoJuego extends PhysicsGameState {


    public EstadoJuego() {
        super("juego");
      
       
        simpleInitGame();
    }....


protected void initCamera() {
      DisplaySystem display = DisplaySystem.getDisplaySystem();
      
      cam = display.getRenderer().createCamera(
            display.getWidth(),
            display.getHeight());
      
      cam.setFrustumPerspective(45.0f,
            (float) display.getWidth() /
            (float) display.getHeight(), 1, 1000);
      
      cam.update();
      
      
   } 

i think the default SimpleGame or SimplePhysicsGame in your case, is not meant to be used with GameStates.

They will not get updated.



Try to add a GameStateManager.create() in simpleInit() and GameStateManager.update()/render() in SimplePhysicsGame's simpleUpdate() and simpleRender() methods.

Maybe GameStateManager could be an attribute of StandardGame since it actually can only be used with StandardGame. It could avoid this misunderstanding.

If someone wants to use that with simple game or something its just instance a GameStateManager.

Or am i missing something?

SimpleGame is just a SimpleGame :slight_smile:

Its mostly just to show off things or to prototype.



If you make your own Game, you will make your own Implementation of a *Game class or use StandardGame.

And you can use GameStates and GameStateManager without  StandardGame, if you wish. Just look at how StandardGame is implemented.

jjmontes said:

And you can use GameStates and GameStateManager without  StandardGame, if you wish. Just look at how StandardGame is implemented.



So if you wish to use, you wuold instance it.
Because GameStates doesn't work alone so it cuold be "linked" to an AbstractGame. IMO.