Class GameSound

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

public final class GameSound extends Sound
Represents a game sound instance, i.e a sound effect of the game which was played for a particular player (see Player.playGameSound(java.lang.String)).
One-shot sounds are released automatically once they have finished playing. Loop sounds keep playing until you call Sound.stop(boolean), or until the player disconnects.

Example: Play a campfire sound as loop, change its volume and stop it later
1//Play the loop sound at the given position
2GameSound sound = player.playGameSound("fire_campfire", new Vector3f(250f, 75f, -42f));
3
4//Reduce the volume
5sound.setVolume(0.5f);
6
7//...
8
9//Stop the sound (with fade out) if you don't want it to play anymore
10sound.stop(false);
  • Method Details

    • setParameter

      public void setParameter(String name, float value)
      Sets the value of a sound parameter. Only certain game sounds have parameters, the available parameters and value ranges depend on the particular sound. Unknown parameters are ignored.
      Parameters:
      name - the (case sensitive) name of the parameter.
      value - the new parameter value.
    • triggerCue

      public void triggerCue()
      Triggers the cue of this sound, i.e releases the sustain point of the sound so it continues playing beyond it. Typically sounds which have a distinct start, loop and end part stay in their loop part until the cue is triggered, then they play their end part and stop. Has no effect if the sound has no sustain point.