The game file to import and load for this session is 5961_08_04.stencyl
.
Sound Track Playing
.Play Sound Track
, and configure it as shown in the following screenshot:Trigger Sound Track
and configure it as shown in the following screenshot:We've added a soundtrack, which plays automatically when the game first loads!
After downloading the soundtrack from StencylForge, we created a new Boolean attribute in the Sound Management
behavior. This attribute will be used to determine whether or not the soundtrack has already been started. Although we don't need it at the moment, it's a good idea to monitor the playing status of the soundtrack, so it will be easier to manage if more advanced sound features are added into the game in the future.
With the Sound Track Playing
attribute in place, we then created a custom event called Play Sound Track
, which listens for the PlaySoundTrack
trigger. When the trigger occurs, this event checks that we haven't already started the soundtrack, and if we haven't, it starts playing the music in a loop
, which means that it will start again as soon as it ends.
Our final step was to trigger the PlaySoundTrack
event, and we did this by adding a when created
event to the Main Menu scene. Now, as soon as the game loads, the soundtrack will be triggered after a one-second delay. A delay has been implemented to ensure that all the scene's attached behaviors have been activated and have completed their initialization tasks before attempting to trigger the soundtrack event. If the Main Menu scene attempts to trigger the PlaySoundTrack
event before the Sound Management
behavior has initialized, then the soundtrack will never play!
The issue of delaying the starting of events in Stencyl is one to look out for! If, during development, a behavior just doesn't seem to be doing its job when a scene is first loaded, then consider if a delay or some other logic may be required to ensure that associated events have enough time to be processed first.
The game file to import and load for this session is 5961_08_05.stencyl
.
We've now implemented some sound effects and a soundtrack, but there are many other sound-management features that we could add to our game.
Have a go at implementing the following:
Research popular games and review how they manage sounds from the point of view of the player
Finally, take time to review the available instruction blocks that relate to sound management in Stencyl, and be aware that there are also two very useful sound-related events available (+Add Event | Sounds).
3.143.4.181