Package net.risingworld.api.sounds
Class Sound
java.lang.Object
net.risingworld.api.sounds.Sound
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 Summary
Modifier and TypeMethodDescriptionboolean
int
getID()
int
int
hashCode()
void
setDirection
(Vector3f direction) void
setGameMusicFade
(float fade) Sets automatic fading for the game music if this sound is playing.void
setMinMaxDistance
(float minDist, float maxDist) void
setPaused
(boolean paused) Pauses / unpauses the sound.void
setPitch
(float pitch) Changes the pitch of a sound instance, i.e how fast the sound plays.void
setPosition
(Vector3f position) Changes the world position of a sound.void
setTimelinePosition
(float position, boolean normalized) Changes the track position / timeline position of the sound.void
setVelocity
(Vector3f velocity) void
setVolume
(float volume) Changes the volume of the sound.void
stop
(boolean immediately) Stops and releases the sound effect.
-
Method Details
-
getID
public int getID() -
getPlayerDbID
public int getPlayerDbID() -
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
Changes the world position of a sound. Only works if the sound isn't a 2D sound.- Parameters:
position
- the new world position.
-
setDirection
-
setVelocity
-
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.- Example:
-
equals
-
hashCode
public int hashCode()
-