Time for action – importing a sound effect

The game file to import and load for this session is 5961_08_05.stencyl.

  1. Select Dashboard | Sounds.
  2. In the main panel, click on the Click here to create new Sound option.
  3. Name the sound Monkey Dies and click on Create.
  4. In the Properties panel, ensure that Sound Type is configured as Sound Effect.
  5. In the Import a Sound panel, click on the Import MP3 option to display the file-locator dialog box.
  6. Locate and open the file 5961_08_Monkey_Dies.mp3 from the book's download files.
  7. Note that, in the Import a Sound panel, the MP3 is imported? status is now checked, as shown in the following screenshot:
    Time for action – importing a sound effect
  8. Also note that, in the Properties panel, the Type is set to: Mono / 44100 Hz / No VBR.
  9. Click on the play button in the Sound Player panel at the lower-left corner of the screen to hear the newly imported sound effect.

What just happened?

We have imported an MP3 audio file as a sound effect, and it can now be used in our game as required.

As we have discovered, as long as our audio files are in the correct format, importing our own sounds into a game is a straightforward process.

We created the new sound in the Sounds section of the Dashboard tab, and specified that the sound was a Sound Effect. We then selected the required MP3 file using the file locator and tested the sound to ensure that it had been imported correctly.

Note

If we want to publish our game to a desktop platform, such as MS Windows, we must create an OGG version of the audio file, and import it using the same process by selecting the Import OGG option.

Have a go hero

The game file to import and load for this session is 5961_08_06.stencyl.

We've now imported our own sound effect for use in our game and we also have the skills to import other sounds that we may require, so let's put these skills to good use.

  • Implement the required instructions to play the Monkey Dies sound effect on channel 1, each time the player loses a life.
  • If the monkey jumps immediately after collecting a piece of fruit, the pickup sound effect is interrupted by the jump sound effect. A very simple modification to the Jump SFX event can resolve this problem. (Hint: channel!)
  • Consider where it may be appropriate to play additional sound effects within the game, and implement those sounds.

Take care not to overwhelm the player with sounds, and remember to specify whether the sound is a sound effect or music soundtrack, when importing audio files.

A suggested solution for implementing the Monkey Dies sound effect, together with comments can be found in the download file 5961_08_07.stencyl. The modifications are in the Show Angel event in the Health actor behavior, and the Play Monkey Dies SFX event in the Sound Management scene behavior. The solution to the sound effect interruption can be found in the Jump SFX event.

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

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