In main.lua I have:
--initiate music
local backgroundMusic = Sound.new(backgroundMusicSource)
backgroundMusicVolume = 0.5
backgroundSoundChannel=backgroundMusic:play(0,true)
backgroundSoundChannel:setVolume(backgroundMusicVolume) |
In splashScene.lua I have the function below which is called when the volume up button is clicked. It works fine. When I click the button I get the 2 print statements in the console and each time I click it, the variable backgroundMusicVolume is 0.05 bigger, until it reaches 1 and then it only prints the Raising volume line.
function volumeUpButton:onClick()
print("Raising volume.")
if backgroundMusicVolume < 1 then
backgroundMusicVolume = backgroundMusicVolume + 0.05
print("backgroundMusicVolume = ", backgroundMusicVolume)
end
end |
But when I raise the variable backgroundMusicVolume, the actual volume of the music doesn't change.
When I was programming in löve, I would run this function inside of love.update(dt), which runs every frame and so would update the music volume every frame. But I don't know how to "update" the volume in Gideros. How do I get the volume to change when the volume control buttons are clicked?
Comments
http://giderosmobile.com/forum/uploads/editor/hs/4lwrz2894p4s.png
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Likes: SinisterSoft, Apollo14, MoKaLux
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Well, that was quite simple.
I can't believeI couldn't figure this out.
Make backgroundMusic a global variable and then it should work
Likes: MoKaLux
Likes: antix