Ship, Captain, and Crew: Sounds Good…


Well, one of those things every game needs is sounds. Not just sound effects, but also background music. It’s a really easy way to enhance the game experience without actually changing any part of the game mechanics. The only problem was, I didn’t know how to do it in Godot.

So, after reading several tutorials, and reading Godot Engine’s how to’s and Q/A’s, I started out by adding some music to my game. At first, per the guides, I just added a new child node to my game launch menu that was an AudioSamplePlayer, and added the music to it. Unfortunately, this worked great in the launch menu scene, but as soon as you changed scenes, such as going to the game table scene, the music would abruptly stop.

So I read several more Q/A’s and guides. The problem is, if you put something in a scene, it ends when the scene does. What I needed was a scene that would be always loaded and was outside of the normal game. Per the guide, I then made a scene consisting of just the AudioSamplePlayer, chose music for it, and saved it as it’s own scene, called MusicPlayer.tscn. Then I went to the project settings and added it to the auto loader when the game starts.

But it didn’t work. In fact, the whole game crashed.

Turns out, since my automatic global scaling script changed all the root nodes children’s scales to meet the screen size, it would crash trying to pull the rectangle size of the MusicPlayer scene (since it doesn’t have one). That was a bit frustrating. But, it turned out to be a simple fix. I changed the MusicPlayer scene to have a Control Node as the root node, and gave it the same size as every other scene in the game, 1920×1080. Then it would allow me to set it’s size, and the game would continue. Seemed a bit hacky to me, but to God be the glory, it worked!

Then there was the question of the dice sounds, when the dice hit the table. Granted, later I’ll be going over the dice mechanics code in the game, but for now, it was simple to add to each dice:

func _on_AreaA6_body_entered(body):
if == “TableObject” :
diceA = 6
#print (diceA)

I simply added one audio node to the game table scene, called diceSoundPlayer, added my dice wave sound to it, and then started it with each collision between dice and table. It worked great!

Feel free to check out my project on my GitLab!

Linux – keep it simple.

libGDX music and sound fail….

While finishing my Android app developer course, I ran into this error during game development:


——— beginning of crash
06-09 13:01:19.410 30345-30366/? E/AndroidRuntime: FATAL EXCEPTION: GLThread 758
Process: com.alaskalinuxuser.criticalvelocity, PID: 30345
com.badlogic.gdx.utils.GdxRuntimeException: Error loading audio file: data/spblk.mp3
Note: Internal audio files must be placed in the assets directory.
at com.alaskalinuxuser.criticalvelocity.criticalvelocity.create(
at android.opengl.GLSurfaceView$GLThread.guardedRun(
at android.opengl.GLSurfaceView$
Caused by: data/spblk.mp3
at android.content.res.AssetManager.openAssetFd(Native Method)
at android.content.res.AssetManager.openFd(
at com.alaskalinuxuser.criticalvelocity.criticalvelocity.create(
at android.opengl.GLSurfaceView$GLThread.guardedRun(
at android.opengl.GLSurfaceView$


It took a long time to figure out the issue, so I thought I would try to save someone else the trouble.

It hinges on this line from the libGDX wiki example:

Music music =“data/mymusic.mp3”));

Which my line looked like this:

bgMusic =“data/spblk.mp3”));

Should work right? But it didn’t. I had to change my line to this to make it work:

bgMusic =“spblk.mp3”));

And put the mp3 file in the “assets” folder.

Hopefully, this will save someone else a really long, frustrating search!

Linux – keep it simple.