Package org.newdawn.slick

Examples of org.newdawn.slick.Sound


   * @param filename filename of sound
   * @return handle to sound
   */
  public SoundHandle loadSound(final SoundSystem soundSystem, final String filename) {
    try {
      return new SlickSoundHandle(soundSystem, new Sound(filename));
    } catch (SlickException e) {
      log.warning("loading of '" + filename + "' failed" + e);
    }
    return null;
  }
View Full Code Here


  @Override
  protected void added(Entity e) {
    SoundFile soundFile = soundMapper.get(e);

    try {
      Sound sound = new Sound(soundFile.getSoundFile());
      sound.play(1, 0.3f);
    } catch (SlickException e1) {
      e1.printStackTrace();
    }
  }
View Full Code Here

    if (s == null)
      return null;
    if (!(s instanceof Sound)) {
      String file = s.toString();
      try {
        s = new Sound(file);
      } catch (SlickException e) {
        e.printStackTrace();
        s = null;
      }
      soundMap.put(name, s);
View Full Code Here

      e.printStackTrace();
    }
  }

  public void playSound(String name) {
    Sound s = getSound(name);
    if (s != null)
      s.play();
  }
View Full Code Here

  public void playSound(String name, float x, float y, float z) {
    float w = screen.getWidth();
    float h = screen.getHeight();
    x = 2 * (x - w / 2) / w;
    y = 2 * (h / 2 - y) / h;
    Sound s = getSound(name);
    // System.out.println("play at " + x + "," + y);
    if (s != null)
      s.playAt(x, y, z);
  }
View Full Code Here

   */
  public static void main(String[] args) {

    // Wikipedia Beispielsound in einem neuen Thread abspielen
    try {
      new Sound(
          new URL(
              "http://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg"))
          .play();
    } catch (MalformedURLException e) {
      e.printStackTrace();
View Full Code Here

                getImage(
                    identifier.substring(0,
                        identifier.indexOf('?')))
                    .getFlippedCopy(true, false));
      } else if (identifier.endsWith(".ogg")) { // Sound laden
        this.sounds.put(identifier, new Sound(identifier));
      } else { // Ressourcentyp unbekannt
        throw new ResourceError("Unkown ressource type: " + identifier);
      }
    } catch (SlickException e) {
      throw new ResourceError(e);
View Full Code Here

   * @return Die Sounddatei.
   */
  public Sound getSound(String id) {
    id = normalizeIdentifier(id);

    Sound sound = this.sounds.get(id);
    if (sound == null) {
      load(id);
      return this.sounds.get(id);
    } else {
      return sound;
View Full Code Here

    }

    private void loadSound() {
        try {
            for (int i = 0; i < ambiente.length; i++) {
                ambiente[i] = new Sound("audio/" + i + ".ogg");
            }
            remate[0] = new Sound("audio/remate1.ogg");
            remate[1] = new Sound("audio/remate2.ogg");
            poste[0] = new Sound("audio/poste1.ogg");
            poste[1] = new Sound("audio/poste2.ogg");
            ovacion[0] = new Sound("audio/ovacion1.ogg");
            ovacion[1] = new Sound("audio/ovacion2.ogg");
            gol = new Sound("audio/gol.ogg");
            rebote = new Sound("audio/rebote.ogg");
            silbato = new Sound("audio/silbato.ogg");
        } catch (Exception ex) {
            ex.printStackTrace();
            //nosound
        }
    }
View Full Code Here

        paImage = new Image("imagenes/pausa.png");
        reImage = new Image("imagenes/retrocede.png");
        if (sonidos) {
            try {
                for (int i = 0; i < ambiente.length; i++) {
                    ambiente[i] = new Sound("audio/" + i + ".ogg");
                }
                remate[0] = new Sound("audio/remate1.ogg");
                remate[1] = new Sound("audio/remate2.ogg");
                poste[0] = new Sound("audio/poste1.ogg");
                poste[1] = new Sound("audio/poste2.ogg");
                ovacion[0] = new Sound("audio/ovacion1.ogg");
                ovacion[1] = new Sound("audio/ovacion2.ogg");
                gol = new Sound("audio/gol.ogg");
                rebote = new Sound("audio/rebote.ogg");
                silbato = new Sound("audio/silbato.ogg");
            } catch (Exception ex) {
                ex.printStackTrace();
                //nosound
            }
        }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.Sound

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.