Tutorial - Playing Sounds
You can also play sounds in your cartoons. You should use function Play for this purpose. You should supply a path to a WAV file. This can be a WAV file from our library like "effects/gunshot.wav" or fully qualified path to a WAV file located online like http://www.webcartoonmaker.com/lib/sounds/effects/gunshot.wav or fully qualified path to a WAV file on your hard drive like "c:\\gunshot.wav". Please keep in mind that function Play does not change scene time. The length of a WAV file is unknown during compilation. You should use Sleep () command after this function call to change the time in scene:
void Scene1 ()
{
Play ( "effects/gunshot.wav" );
Sleep ( 1 );
}
There is a good set of 10 seconds long loops available in our library. You can use these loops as backgroud music in your cartoons. Here is an example of such usage:
#include <boy.h>
void Scene1 ()
{
// some actions
Boy Max;
Max.SetVisible ();
Max.SetPos ( 500,290 );
Max.GoesTo ( -500, 290, 30 );
// play music
SetTime ( 0 );
for ( int i=0; i<3; i++ )
{
Play ( "loops/adventurous_americana.wav" );
Sleep ( 10 );
}
}
Try to compile this example to see a boy walking and a music playing!
|