Lesson5: adding sound to your game
OK!
first I will show you the command to play a music file!
Music.playFile("name.mod",true)
Ok the command Music.playFile is easy to understand,
name.wav is the name of the file to play,
true is if you want the song to loop or not (continuously play).
There is also a command
Music.playing()
This command tests if music is playing. we would use this command like this
if Music.playing() == true then
screen:print(100,100,"music is playing", red)
end
also you can use these commands to stop, pause, or play a paused sound file:
Music.resume()
Music.stop()
Music.pause()
Ok but if you are going to use a sound, lets say gunshot, you dont want to load the sound each time!
so you use this command to load a sound
gunshot = Sound.load("gunshot.wav")
Ok?
now to play a loaded sound type
gunshot:play()
ok now to set the volume type this
Music.volume(volume...)
first I will show you the command to play a music file!
Music.playFile("name.mod",true)
Ok the command Music.playFile is easy to understand,
name.wav is the name of the file to play,
true is if you want the song to loop or not (continuously play).
There is also a command
Music.playing()
This command tests if music is playing. we would use this command like this
if Music.playing() == true then
screen:print(100,100,"music is playing", red)
end
also you can use these commands to stop, pause, or play a paused sound file:
Music.resume()
Music.stop()
Music.pause()
Ok but if you are going to use a sound, lets say gunshot, you dont want to load the sound each time!
so you use this command to load a sound
gunshot = Sound.load("gunshot.wav")
Ok?
now to play a loaded sound type
gunshot:play()
ok now to set the volume type this
Music.volume(volume...)