How do you add background music to your game? One of my group members created a music file, but I’m confused where you put the music file and how do you start playing it, preferably forever at this point.
Specifically, if it’s music I recommend ogg vorbis due to file size. Might have to double check if there’s different types of formats within that format. For example playing .wav sound is picky on bitrate etc.
There’s a looping parameter as well, might solve your playing forever need.
The Sound page is too complicated for me. I noticed the 2D Platformer Creation Kit tutorial has quite nice step by step instructions: Add Game Object (to your collection), add Sound component for that object, assign a music file for the Sound component from the Properties panel and choose Play On Awake. And that’s pretty much it.
I’ve updated the sound manual to cover the absolute basics first, adding a sound component and causing it to play its sound. Check it out: https://www.defold.com/manuals/sound/
Nice. I guess there are also sound related tutorials, but I have not been researching that far.
The sound manual explains it all in detail:
Playing a sound/piece of music:
What is that?
That’s not very helpful. I am using the spaceship tutorial & I want to add sounds to it, but can’t figure out how to add the sounds so I hear them. I have right-clicked on the spaceship & added sound & then selected my sound file (which I copied over the project folder), but no sound.
The explanations of adding sounds is very lacking for this game engine.
- Add sound component to Game Object
- Add .wav or .ogg at 44100Hz to sound component
- Add a script to the Game Object
- In the script have the line: