Game Development Reference
In-Depth Information
The example below shows how to specify ranges for the volume and pitch:
CIwSoundSpec
{
name gun2
data gun_shot2
// Choose a random pitch when playing this sound
pitchMin 0.9
pitchMax 1.1
// Choose a random volume when playing this sound
volMin 0.9
volMax 1.1
// Do we want this sound to loop?
looping false
}
Another useful class that we have access to is CIwSoundGroup . This allows us to
collect a number of different sound effects together and pause, resume, stop, or alter
the volume or pitch of any that are currently being played all at the same time. Note
that a sound group only allows a single volume or pitch value to be specified, not a
random range:
CIwSoundGroup
{
name guns
// Reduce volume of all gun sounds by a half
vol 0.5
// Include the gun1 sound in this group
addSpec gun1
}
Sounds can be added to groups using the addSpec keyword, or alternatively you
can add CIwSoundSpec to a group when it is defined by using the group keyword
followed by the group name, in its definition. We can use either method, but the
group or sound must have been declared before we make reference to it.
 
Search WWH ::




Custom Search