Game Development Reference
In-Depth Information
To access a sound specification or group, we just load the GROUP file and retrieve
them using the resource manager in the normal way. Here's an example:
IwGetResManager()->LoadGroup("sounds.group");
CIwSoundSpec* lpGunSpec = static_cast<CIwSoundSpec*>(
IwGetResManager()->GetResNamed("gun1", "CIwSoundSpec"));
CIwSoundGroup* lpGunsGroup = static_cast<CIwSoundGroup*>(
IwGetResManager()->GetResNamed("guns", "CIwSoundGroup"));
Playing, stopping, and altering sound
parameters
Once we have hold of a pointer to
CIwSoundSpec
we can start playing it by calling
the
Play
method, which will do all the behind-the-scenes stuff of allocating a free
channel and setting volume and playback speed. The
Play
method can be passed an
optional parameter, which is an instance of the class
CIwSoundParams
, that allows
the volume and pitch to be modified when starting the sound.
The
Play
method returns a pointer to a
CIwSoundInst
class, which has methods to
allow that single instance of the sound to have its volume or pitch modified, and also
provides methods called
Pause
,
Resume
, and
Stop
, which should be self explanatory!
If no free sound channel is available, the
Play
method will return
NULL
.
If we have a pointer to
CIwSoundGroup
we can affect all currently playing instances
of sounds contained within it. Again there are
Pause
,
Resume
, and
Stop
methods that
do what you would expect, plus there are the methods
SetVol
and
SetPitch
that
will scale the current volume and pitch of the sounds. These methods use the value
IW_GEOM_ONE
(4096) to indicate a scale of one.
The s3eVideo API
We'll finish our look at Marmalade's multimedia support by having a whirlwind
look at support for playing video clips using the s3eVideo API. To make use of
the functions it provides, we just need to include the
s3eVideo.h
file into our
source code.
Search WWH ::
Custom Search