Examining the play sound instruction blocks

In Stencyl, we have two main options for playing sounds, as shown in the following screenshot:

Examining the play sound instruction blocks

The first option, Play Sound, does exactly what it states. Sounds played with this instruction can have their volume and fading controlled by the general-purpose sound-control instructions, set volume to … % and Fade In over … secs, which can be seen in the following screenshot:

Examining the play sound instruction blocks

These general-purpose sound controls work well in many circumstances, but the disadvantage is that all sounds played with the Play Sound instruction will simultaneously be altered using the volume and fade instructions; every sound currently being played will fade, or will have its volume changed at the same time and at the same level.

The second option, Play Sound on channel …, provides additional flexibility; we can play any sound on any one of 32 channels. This provides us with the opportunity, if required, to control different sounds depending on our requirements. We can see that, using the two instruction blocks shown as follows, we can stop sounds on any channel, and we can also fade sounds in and out on any channel:

Examining the play sound instruction blocks

For example, we may want to have a soundtrack playing at a fixed volume throughout the game, but we may also want to fade in certain special effects at the same time, without affecting the volume of the main soundtrack. Playing the soundtrack and the special effects on different channels provides us with the required flexibility.

Currently, we don't need to vary the volumes of different sounds in our game, but we're going to play all our standard special effects on channel 1, so we can control them separately if we need to in the future.

It's useful to note that the Play Sound and Play Sound on channel … instruction blocks can have the Play option changed to Loop, so the sound will repeat indefinitely, until we tell it to stop playing. This can be useful for repeating soundtracks, or for repeatedly playing a sound effect until we explicitly tell it to stop.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.156.75