O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — loading the game sound effects

To load sounds into the game, we will create a method called LoadSounds.

  1. Inside the game class, add a new method header called LoadSounds
    Method LoadSounds:Int ()
    
  2. Load the"bing" sound into the sndBing object. Remember: don't add the file extension of your sound file to the filename. Now, close the method.
    sndBing = eng.LoadSound("bing")
    Return 0
    End
    

What just happened?

With this separate method to load sounds, it will be easy for you to add other sounds as well. Just create another sound object in the data section, and then load the sound here.

Game layers

Layers are like groups. They are rendered in their order of creation, unless you tell the engine to do it otherwise.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required