Exemplo n.º 1
0
  private void initAudio() {
    bgAudio = new AudioNode(assetManager, "Sound/Background.wav", false);
    bgAudio.setLooping(true);
    bgAudio.setVolume(3);
    rootNode.attachChild(bgAudio);
    bgAudio.play();

    explosionAudio = new AudioNode(assetManager, "Sound/Explosion.wav", false);
    explosionAudio.setLooping(false);
    explosionAudio.setVolume(0.5f);
    rootNode.attachChild(explosionAudio);

    AudioNode accelAudio = new AudioNode(assetManager, "Sound/Fire4.wav", false);
    accelAudio.setLooping(true);
    accelAudio.setVolume(10);
    spaceship.initAudio("Accelerate", accelAudio);

    AudioNode laserAudio = new AudioNode(assetManager, "Sound/Laser.wav", false);
    laserAudio.setLooping(false);
    laserAudio.setVolume(1);
    spaceship.initAudio("Laser", laserAudio);
  }
  @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");
  }