Hi,
In my new game, there is a day/night transition that occur when the player reach the needed distance.
I use 2 different music, one for the day and one for the night and I change between them like this:
[lua]if(player.distance > distanceJour) then
distanceJour = distanceJour+50
if(currentDay == “Jour”)then
currentDay = “Soir”
transition.to(filtreSoir, { time=500, alpha = 0.4} )
elseif(currentDay == “Soir”)then
audio.fadeOut( backgroundMusic, { channel=3, time=2000 } )
audio.setVolume( 1, { channel=4 } )
audio.play( backgroundMusicNight, { channel=4, loops=-1, fadein=1000 } )
currentDay = “Nuit”
transition.to(filtreNuit, { time=500, alpha = 0.6} )
transition.to(filtreSoir, { time=500, alpha = 0} )
elseif(currentDay == “Nuit”)then
audio.fadeOut( backgroundMusicNight,{ channel=4, time=2000} )
audio.setVolume( 1, { channel=3 } )
audio.play( backgroundMusic, { channel=3, loops=-1, fadein=1000 } )
currentDay = “Matin”
transition.to(filtreSoir, { time=500, alpha = 0.4} )
transition.to(filtreNuit, { time=500, alpha = 0} )
elseif(currentDay == “Matin”)then
currentDay = “Jour”
transition.to(filtreNuit, { time=500, alpha = 0} )
transition.to(filtreSoir, { time=500, alpha = 0} )
end
end[/lua]
And that work really great! The song cycle between each other. The problem is that when I use the fadeOut, even if I specify the channel, the sound in my games all fade out with the music.
For short story, in the game, we control a Rocket. When we press the screen, the Rocket goes up and when we release, it fall. So for the time we press the screen, I want to have a fire sound that loop indefinitly.
I create the sound at the beginning of the game, like this :
fire = audio.play( fire,{loop=-1, channel= 2} )
And I cycle the fire like this:
[lua]if(fall == true) then
tnt:newTransition( player, { rotation = 45, time=400 } )
player:prepare(“idle”)
player:play()
fire = audio.pause( {channel = 2} )
fire = audio.rewind( { channel = 2 } )
end
if(fall == false)then
tnt:newTransition( player, { rotation = -45, time=400 } )
player:prepare(“engine”)
player:play()
fire = audio.resume( fire,{channel= 2} )
end[/lua]
Again, everything work just fine…but when I reach the correct distance, the fadeOut on the background music(On channel 3) actually fadeOut the fire sound too(On channel 2)! Actually, even if I remove the first fadeOut, the second fade out, for the second music(On Channel 4) Still fadeOut the fire sound…
So, does anyone know what i’m doing wrong? Why the fadeOut on channel 3 affect another channel?
Thank you! [import]uid: 181680 topic_id: 35536 reply_id: 335536[/import]