Class Sound

java.lang.Object
net.risingworld.api.sounds.Sound

public final class Sound extends Object
Represents a sound instance (typically bound to a particular player). This is either a game sound or a custom sound (represented by a SoundAsset).
  • Method Details

    • getID

      public int getID()
    • getPlayerDbID

      public int getPlayerDbID()
    • getPlayer

      public Player getPlayer()
    • setPaused

      public void setPaused(boolean paused)
      Pauses / unpauses the sound.
      Parameters:
      paused - true to pause the sound (so it stops playing), false to continue playing.
    • setVolume

      public void setVolume(float volume)
      Changes the volume of the sound.
      Parameters:
      volume - the new sound volume (default: 1.0)
    • setPitch

      public void setPitch(float pitch)
      Changes the pitch of a sound instance, i.e how fast the sound plays.
      Parameters:
      pitch - the new sound pitch (default: 1.0)
    • setTimelinePosition

      public void setTimelinePosition(float position, boolean normalized)
      Changes the track position / timeline position of the sound.
      Parameters:
      position - the new timeline position in seconds. If "normalized" is true, use a value between 0 and 1.
      normalized - false to use absolute values (seconds), true to use a value relative to the total length of the sound (0-1).
    • setPosition

      public void setPosition(Vector3f position)
      Changes the world position of a sound. Only works if the sound isn't a 2D sound.
      Parameters:
      position - the new world position.
    • setDirection

      public void setDirection(Vector3f direction)
    • setVelocity

      public void setVelocity(Vector3f velocity)
    • setMinMaxDistance

      public void setMinMaxDistance(float minDist, float maxDist)
    • setGameMusicFade

      public void setGameMusicFade(float fade)
      Sets automatic fading for the game music if this sound is playing. This is useful if you want to play music through the API, but don't want the game music to interfere with it. If used with a 3D sound, the fading will only be performed if the player is in proximity of the sound.
      Parameters:
      fade - determines how much the game music should be faded. 0 (default) for no fading (i.e game music keeps playing with 100% volume), 1 for 100% fading (i.e game music is no longer hearable).
    • stop

      public void stop(boolean immediately)
      Stops and releases the sound effect. Usually this is only necessary when playing a loop sound, for example. One-shot sounds (non-loop sounds) are stopped and released automatically.
      Parameters:
      immediately - if true, the sound stops immediately - otherwise it will fade out (depending on the sound). It's recommended to set this parameter to false.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object