android.gameengine.icadroids.sound
Class GameSound

java.lang.Object
  extended by android.gameengine.icadroids.sound.GameSound

public final class GameSound
extends java.lang.Object

This class features a number of static methods that can be used to add sound to your game. This class should be used when you want to play short sound clips, the length of these clips should not be longer than about 5 seconds. For larger files, use the MusicPlayer class.

Author:
Leon & Lex

Constructor Summary
GameSound()
          Constructs an instance of this class.
 
Method Summary
static void addSound(int index, java.lang.String soundID)
          Adds a new sound to the SoundPool.
static void cleanup()
          Deallocates the resources and Instance of GameSound.This is called automatically when the application is be closed.
static void initSounds(Context theContext)
          Initializes the storage for the sounds.
static void pauseSound(int index)
          Pause a sound, call resumeSound to continue playing the specified sound.
static void pauseSounds()
          Pauses all sounds, call resumeSounds to continue playing sounds.
static void playSound(int index, int loopSound)
          Plays a sound that has been added to the SoundPool with addSound
static void resumeSound(int index)
          Resumes the specified paused sound.
static void resumeSounds()
          Resumes all paused sounds.
static void stopSound(int index)
          Stops a sound
static void stopSounds()
          Stops all sounds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameSound

public GameSound()
Constructs an instance of this class.

Method Detail

initSounds

public static final void initSounds(Context theContext)
Initializes the storage for the sounds.

Parameters:
theContext - The Application context.

addSound

public static final void addSound(int index,
                                  java.lang.String soundID)
Adds a new sound to the SoundPool. Call this method to store a sound, you can then retrieve the sound from the SoundPool with the playSound function.

Parameters:
index - The sound index where the sound will be stored.
soundID - The name of the sound that needs to be stored.

playSound

public static final void playSound(int index,
                                   int loopSound)
Plays a sound that has been added to the SoundPool with addSound

Parameters:
index - The Index of the Sound to be played, defined by addSound.
loopSound - The amount of times the music should loop, a negative value will result in an endless loop.

pauseSound

public static final void pauseSound(int index)
Pause a sound, call resumeSound to continue playing the specified sound.

Parameters:
index - index of the sound to be paused.

pauseSounds

public static final void pauseSounds()
Pauses all sounds, call resumeSounds to continue playing sounds.


resumeSound

public static final void resumeSound(int index)
Resumes the specified paused sound.

Parameters:
index - index of the sound to be resumed

resumeSounds

public static final void resumeSounds()
Resumes all paused sounds.


stopSound

public static final void stopSound(int index)
Stops a sound

Parameters:
index - index of the sound to be stopped

stopSounds

public static final void stopSounds()
Stops all sounds.


cleanup

public static final void cleanup()
Deallocates the resources and Instance of GameSound.This is called automatically when the application is be closed.