Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How do I "update" sound in my game — Gideros Forum

How do I "update" sound in my game

rpallenrpallen Member
edited January 2018 in General questions
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

Sign In or Register to comment.