It looks like you're new here. If you want to get involved, click one of these buttons!
-loading application settings sets = dataSaver.loadValue("sets") --if sets not define (first launch) --define defaults if(not sets) then sets = {} sets.music = true dataSaver.saveValue("sets", sets) end -- Loads sounds music = {} music.theme = Sound.new("sounds/music.mp3") --turn music on music.on = function() if not music.channel then sets.music = true dataSaver.saveValue("sets", sets) end end --turn music off music.off = function() if music.channel then sets.music = false dataSaver.saveValue("sets", sets) end end the options menu looks like this: musicOnButton = Button.new(imgBtnMusicOn, imgBtnMusicOn, 2) musicOffButton = Button.new(imgBtnMusicOff, imgBtnMusicOff, 2) musicOnButton:setPosition((screenWidth-imgBtnMusicOn:getWidth())/2, imgPlaceholder:getY() + imgPlaceholder:getHeight() + 20) musicOffButton:setPosition((screenWidth-imgBtnMusicOn:getWidth())/2, imgPlaceholder:getY() + imgPlaceholder:getHeight() + 20) musicOnButton:addEventListener("click", function() self:removeChild(musicOnButton) sets.music = true dataSaver.saveValue("sets", sets) music.off() self:addChild(musicOffButton) end ) musicOffButton:addEventListener("click", function() self:removeChild(musicOffButton) sets.music = false dataSaver.saveValue("sets", sets) music.on() self:addChild(musicOnButton) end ) if sets.music then self:addChild(musicOnButton) else self:addChild(musicOffButton) end and in my game i called this: if sets.music then music.channel = music.theme:play(0,1000000) end |
Comments
if sets:get("music")
self:addChild(musicOnButton)
else
self:addChild(musicOffButton)
end
you can try to trace the value of sets.music with