예제 #1
0
 @Override
 public void simpleInitApp() {
   src = new AudioNode(assetManager, "Sounds/Effects/Foot steps.ogg", true);
   src.setVolume(10);
   System.out.println("Playing all frequencies unfiltered");
   src.play();
 }
  @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");
  }
  @Override
  public void cleanup() {
    localRootNode.removeLight(ai);
    localRootNode.removeLight(dl);

    this.app.getTimer().reset();
    rootNode.detachChild(localRootNode);
    viewPort.removeProcessor(niftyDisplay);
    audio.stop();
    nifty.exit();
    cam.setRotation(Quaternion.IDENTITY);
    cam.setLocation(Vector3f.ZERO);
    cam.setViewPort(0, 1, 0, 1);
    super.cleanup();
  }
예제 #4
0
 @Override
 public void simpleUpdate(float tpf) {
   if (src.getStatus() != src.getStatus().Playing) {
     filterIsOn = !filterIsOn; // toggle
     src = new AudioNode(assetManager, "Sounds/Effects/Foot steps.ogg", true);
     if (filterIsOn) {
       src.setDryFilter(new LowPassFilter(.5f, .1f));
       System.out.println("Playing with low pass filter");
     } else {
       src.setDryFilter(new LowPassFilter(1f, 1f));
       System.out.println("Playing all frequencies unfiltered");
     }
     src.setVolume(10);
     src.play();
   }
 }
예제 #5
0
  public void generateExplosion(Vector3f position) {
    ParticleEmitter explosion = new ParticleEmitter("Explosion", ParticleMesh.Type.Triangle, 10);
    Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
    explosion.setMaterial(mat_red);
    explosion.setImagesX(2);
    explosion.setImagesY(2); // 2x2 texture animation
    explosion.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f)); // red
    explosion.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow
    explosion.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 0));
    explosion.setGravity(0, 0, 0);
    explosion.setStartSize(2);
    explosion.setEndSize(4);
    explosion.setLowLife(1);
    explosion.setHighLife(2);
    explosion.setParticlesPerSec(0);
    explosion.getParticleInfluencer().setVelocityVariation(4);
    explosion.setLocalTranslation(position);
    explosions.attachChild(explosion);
    explosion.emitAllParticles();

    explosionAudio.playInstance();
  }
예제 #6
0
파일: Duck.java 프로젝트: barthoz/ogogame
 /** Business Logic */
 public void quack(AudioNode audio, boolean force) {
   if (quackable || force) {
     audio.playInstance();
     quackable = false;
   }
 }
예제 #7
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);
  }
예제 #8
0
 public SoundHandle loadSound(SoundSystem soundSystem, String filename) {
   AudioNode an = new AudioNode(assetManager, filename, false);
   an.setPositional(false);
   return new SoundHandleJme(ar, an);
 }