Package util
Enum SoundEffects
- All Implemented Interfaces:
Configuration,Serializable,Comparable<SoundEffects>,java.lang.constant.Constable,EventListener,LineListener
- Author:
- Krish Pillai
This enum provides basic sound functionality:
- WIN
- LOSE
- COLLIDE
- STARTUP
- SHOOT
- BOUNCE
These enumerations support play, delayed play, loop, and stop operations.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>Nested classes/interfaces inherited from interface common.Configuration
Configuration.Direction -
Enum Constant Summary
Enum Constants -
Field Summary
Fields inherited from interface common.Configuration
AUDIO_DIR, DEFAULT_FRAME_RATE, DRAWABLE_DIR, GAMELOGGER, setViewCallChain -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinit()Calling init() will invoke constructors on all enums.voidloop()Play the audio file in an endless loop (continuously).voidloop(int count) Loops for the specified number of times.voidloop(int count, long delay) Play the audio in an endless loop.voidplay()Starts play-back instantaneously.voidplay(long delay) Starts play-back after specified delay.voidrewind()Set the current frame position to zero (the beginning)voidsetVolume(float db) Sets the volume level of the clip.voidstop()Stops current play-back instantaneously.voidstop(long delay) Stops play-back after specified delay.voidCallback for the Media Player (Line listener)static SoundEffectsReturns the enum constant of this type with the specified name.static SoundEffects[]values()Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
WIN
Standard win jingle -
LOSE
Standard lose jingle -
COLLIDE
Clip for collisions -
STARTUP
Clip for start of game -
SHOOT
Standard shooting noise -
POP
Standard popping noise -
BOUNCE
Bounce of soccer ball -
SMASH
Smash glass bottle
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
play
public void play()Starts play-back instantaneously. Runs in the background and is a non-blocking call.- See Also:
-
loop
public void loop()Play the audio file in an endless loop (continuously). This is a non-blocking call.- See Also:
-
loop
public void loop(int count) Loops for the specified number of times. This is a non-blocking call.- Parameters:
count- The number of iterations to play- See Also:
-
rewind
public void rewind()Set the current frame position to zero (the beginning) -
loop
public void loop(int count, long delay) Play the audio in an endless loop. This is a non-blocking call. Starts looping play-back from the current position. Arguments are count, specifying the number of repetitions of the loop, and the delay after which the play-back should begin.- Parameters:
count- The number of times for loop to rundelay- The delay before playback begins (milliseconds)- See Also:
-
stop
public void stop(long delay) Stops play-back after specified delay. For instantaneous stoppage, usestop(). This is a non-blocking call.- Parameters:
delay- The delay before playback begins (milliseconds)- See Also:
-
stop
public void stop()Stops current play-back instantaneously.- See Also:
-
play
public void play(long delay) Starts play-back after specified delay. A delay of zero starts play instantly. This is a non-blocking call.- Parameters:
delay- Milliseconds to wait before playing.- See Also:
-
init
public static void init()Calling init() will invoke constructors on all enums. This method can be used to explicitly preload audio files and avoid in-game lag from initial loading.- See Also:
-
update
Callback for the Media Player (Line listener)- Specified by:
updatein interfaceLineListener
-
setVolume
public void setVolume(float db) Sets the volume level of the clip. Zero db corresponds to no amplification. A negative value decreases volume. Positive value increases volume.- Parameters:
db- Value in decibels- See Also:
-