@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); this.app = (SimpleApplication) app; this.assetManager = this.app.getAssetManager(); this.inputManager = this.app.getInputManager(); this.cam = this.app.getCamera(); this.stateManager = stateManager; this.guiNode = this.app.getGuiNode(); this.rootNode = this.app.getRootNode(); this.audioRenderer = this.app.getAudioRenderer(); this.viewPort = this.app.getViewPort(); this.space = this.stateManager.getState(BulletAppState.class).getPhysicsSpace(); this.guiViewPort = this.app.getGuiViewPort(); rootNode.attachChild(localRootNode); factory = new GameFactory(); gameState = new RaceObjects(); niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, viewPort); nifty = niftyDisplay.getNifty(); nifty.fromXml("Interface/Nifty/startscreen.xml", "start", this); guiViewPort.addProcessor(niftyDisplay); audio = new AudioNode(this.app.getAssetManager(), "Sounds/default.wav"); audio.play(); audio.setLooping(true); textfield = nifty.getScreen("name").findNiftyControl("name", TextField.class); settingsList = nifty.getScreen("settings").findNiftyControl("resolutions", ListBox.class); settingsList.addItem("640*480 32bpp"); settingsList.addItem("800*600 32bpp"); settingsList.addItem("864*648 32bpp"); settingsList.addItem("960*720 32bpp"); settingsList.addItem("1024*768 32bpp"); popup = nifty.createPopup("popupExit"); }
public void nextScreen(String name) { if (name.equals("controls")) { nifty.gotoScreen(name); } if (name.equals("name")) { nifty.gotoScreen(name); } if (name.equals("start")) { nifty.gotoScreen(name); space.remove(car_con[index]); localRootNode.detachChild(cars[index]); localRootNode.removeLight(ai); localRootNode.removeLight(dl); localRootNode.detachChild(floor); } if (name.equals("settings")) { nifty.gotoScreen(name); } if (name.equals("credits")) { nifty.gotoScreen(name); } if (name.equals("startMenu")) { nifty.gotoScreen("start"); } if (name.equals("carSelect")) { playerName = textfield.getText(); if (!"".equals(playerName)) { nifty.gotoScreen(name); showCar(); } } if (name.equals("startSettings")) { int res = settingsList.getFocusItemIndex(); boolean fullScreen = true; boolean vSync = true; AppSettings settings = new AppSettings(true); settings.setFullscreen(fullScreen); settings.setVSync(vSync); settings.setResolution(width[res], height[res]); app.setSettings(settings); nifty.gotoScreen("start"); } }