Home > Hitchhiker's Guide to Games, Software Development > Lab[3] = Make Some Noise

Lab[3] = Make Some Noise

Note: If you tried this lab on or before 8/29/2013, there was an error in the original code. Please download the code again.


  • Run the Jaalaga starting code on a device
  • Pick different sounds
  • Update the credits screen if you use different sounds

What You Will Need

Lab Version

  • Version 0.3


In Lab[0] we setup a development environment. Our development environment at this point includes several software tools, the AndEngine source code and our Android or Kindle Device. Among the code was a project with a wide variety of AndEngine examples. You should have reached a point where you ran these examples on your device. If you did not reach this point you should get Lab[0] working before tackling this lab because it requires a working AndEngine setup.


In this lab we take what we accomplished in lab[2] and add some excitement with some sounds. Audio is an important element to a game because it can is another way to convey to the player what is going on in the game world. Tense music and sound effects can add an extra level of challenge to any game. In the interest of keeping these labs shorts, we will focus our audio efforts on replacing existing sounds.


Run the Starting Code for Lab 3

First you will need to get the starting code from Git Hub at the link described above. Add this project to your working setup from Lab[0]. Note, if you changed the graphics in the previous labs, you can update just the “src” folder and the “assets/sounds” folder.  Compile and run the code. You should now hear sounds when a missile is fired or when a missile collides with an enemy. If you are happy with the sounds, you are done!

Update the Sounds

The source code for this lab and future labs will be marked with comments that have TODO at the beginning. This lab has x such comments

Original Sounds

The player missile fire sound is a creative commons attribution sound. Therefore the sound shows up in the credits. Here is the original sound: http://www.freesound.org/people/bubaproducer/sounds/151022/ This file is saved as playerFire.mp3 and is stored in /assets/sound/

The collision sound is another creative commons attribution sound. It is also listed on the credits scene. The original sound can be found here: http://www.freesound.org/people/Robinhood76/sounds/187647/  This file is saved as enemyExplosion.mp3 and is stored in /assets/sound/

Replace Sounds

If you want to use different sounds, replace the mp3 files mentioned above to a file with a different sound. Make sure they are fairly short because the audio pool is a small, finite size. If you load a sound that is too big to fit into memory, AndEngine will simply not play the sound.

Update the Credits

See the new file JaalagaCredits.java for code that displays the credits screen. When using sound from FreeSound.org, or any source, you should comply with the license terms. Attribute means give the author credit. Non-commercial means you can’t use the sound if you intend to publish an app for profit. Honoring license terms is the right thing to do as a content creator. If you can’t or don’t want to comply with the license terms, simply don’t use the work.

  1. November 29, 2013 at 4:40 am

    After downloading the new source code. The credits work but when starting the game it crashes. Was anything changed?

    • November 29, 2013 at 4:51 am

      Seeing these warnings? Is this the issue?

      Description Resource Path Location Type
      Array is a raw type. References to generic type Array should be parameterized Array.java /AndEnginePhysicsBox2DExtension/src/com/badlogic/gdx/utils line 73 Java Problem

      • November 29, 2013 at 5:10 am

        I do notice that AndEngine prints a variety of Warnings to the log. This warning I don’t think we will need to worry about. If there are other messages that start with an “E” for Error then we should definately consider. Messages printed by the game will have “Jaalaga” as the source. You should see a few in there for things like resources loading.

    • November 29, 2013 at 5:05 am

      See my response below Justin.

  2. November 29, 2013 at 5:04 am

    Yes what was added was the load of the sounds. The sounds are delay loaded (that is to say they don’t load until the game screen) so the fact that it crashed when the game was loaded tells me that the game screen may be consuming too much memory. There are two ways to determine what is going on. One is to look at the system log. This shows up when you are debugging with a USB cable in Eclipse or you can view the system log with many free apps.

    The other way to debug this is to go to the resource manager (JaalagaResourceManager.java) and look for the loadGameResources() method (Line 193 in the code). Inside of that method there is a line that says “this.loadGameSounds();”. (Line 196) You can comment this out and rerun. You “comment out” a line by putting two forward slashes in front of the line (i.e. change “this.loadGameSounds();” to “//this.loadGameSounds(); It will change color in Eclipse when you do this to indicate it is now a comment. If it runs with the load sounds commented out we probably have a memory issue.

    If either by looking at the log or commenting out the sound load call you are able to determine there is a memory problem, we have a real world problem to fix 🙂 I tried this on an Galaxy S3 Sky Rocket and an Intel based Android Tablet. It worked ok there, but that does not mean other devices won’t have problems. Other devices may have less memory. In which case I will need to look at how we can be more efficient with game resources. Let me know how your experiments go and I will look a reworking the code to be more space efficient.

  3. November 30, 2013 at 3:59 am

    Ok. It’s not a memory issue. It was having issues loading .png files. The rocket and button. Thanks

    • November 30, 2013 at 4:06 am

      Great catch! I will upload them shortly.

    • November 30, 2013 at 4:17 am

      It is fixed now! The link is the same, but it it points to a new version.

      • December 1, 2013 at 2:17 am

        Thanks! I made my own but for some reason it didn’t like them. Yours worked fine though.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: