Loading up a new Game Map

Hi folks, I’m trying to determine the best way to loadup a new ‘map’ into my game.



Here is what I’m currently doing:



[java]

stateManager.detach(bulletAppState);

rootNode.detachAllChildren();

bulletAppState = new BulletAppState();

bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);

stateManager.attach(bulletAppState);

[/java]



My question is…is this enough? i.e.

will the above actions:

  1. remove previously loaded assets (assuming I have no other objects referencing those assets?)
  2. remove PhysicsControls from the physics Space? or do these need to be removed manually? (I’m guessing manually)
  3. I’m Using nifty…after the above actions, nifty no longer appears to function at all :frowning:



    note: Nifty is setup initially using the following sequence (this sequence is NOT re-executed when loading up the new map)



    [java]



    if (niftyEnabled) {

    // UI - Callback Class

    startScreen = new StartScreen();

    stateManager.attach(startScreen);





    niftyDisplay = new NiftyJmeDisplay(

    assetManager,

    inputManager,

    audioRenderer,

    guiViewPort);

    Nifty nifty = niftyDisplay.getNifty();

    guiViewPort.addProcessor(niftyDisplay);

    nifty.fromXml(“Interface/gui.xml”, “start”, startScreen);

    // needed for nifty?

    flyCam.setDragToRotate(true);

    }

    [/java]



    I figure nifty should still functional after the above tear-down, since its not directly attached to the schene graph?

    or am I missing something here…I’m guessing I am…but…

no, you have to do everything you did before in reverse. that is remove all physics objects from the phyiscs space, remove all spatials from the scenegraph etc.

2 Likes