Hi Brent ,
Thank you for your reply , let me give you a little more info on my project. I have 3 lua files: main.lua , scene_menu.lua and scene_game.lua.
I have loaded all the sounds and back ground music in main.lua as follows:
_BACKGROUNDMUSIC = audio.loadStream (“backgroundB.mp3”)
_HIT= audio.loadSound(“blast.mp3”)
_KILL = audio.loadSound(“boing-1.wav”)
_POP= audio.loadSound(“burst.wav”)
_CLICK= audio.loadSound(“click.mp3”)
_FLAPPING = audio.loadSound(“Flapping.wav”)
scene_menu.lua is the main menu screen for my game. I have created a widget button to mute all sounds and music in the game on this screen as follows:
local function onSoundsTouch(event)
if(event.phase == “ended” ) then
– mute the game
audio.setVolume(0)
else
– unmute the game
audio.setVolume(1)
end
end
btn_sounds = widget.newButton {
width = 50,
height = 50,
defaultFile = “SoundOff.png”,
overFile = “SoundOff_Overlay.png”,
onEvent = onSoundsTouch
}
btn_sounds.x = _R - 25
btn_sounds.y = _B - 25
sceneGroup: insert(btn_sounds)
I am able to mute the sounds on the main menu however once i start the game , the music and sounds all resume. How can i make sure that when the sound off button is pressed on the menu screen all sounds and music stay muted when the player starts the game.