Book Image

Stencyl Essentials

By : Richard Sneyd
Book Image

Stencyl Essentials

By: Richard Sneyd

Overview of this book

Table of Contents (20 chapters)
Stencyl Essentials
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Index

Playing sound FX and music in Stencyl


Well done! You have now successfully imported both music and sound FX files. Now all that remains is to trigger them in the code. Perform the following steps to do so:

  1. Open up the Player Handler behavior, and in the events pane, switch to Created, as shown in the following screenshot:

  2. In the blocks palette, go to Sound & Images | Sound | Playback, then drag out a Play Sound block, and add it to the stock of blocks in the when created event block, as shown in the following screenshot:

  3. Change Play to Loop, as shown in the following screenshot:

  4. Navigate to Sound | Choose Sound, as shown in the following screenshot, then select Country Music, and click on OK to commit, as shown in the following screenshot:

Now, when we test the game, Country Music will start looping at the beginning of every game level! Next, we need to trigger the Whip Away Sound FX whenever we whip a rock. Perform the following steps to do so:

  1. In the events pane, go to Custom Block in the...