I’m having a lot of trouble with my audio. I want it to play after the game countdown, which I can do. The only problem is I don’t know how to make it to where I can push the restart button, have it take me to the loading scene, come back to the game, and after the countdown, play the audio from the beginning. I have tried rewinding, but that doesn’t work. Here is a little bit of my code:
[lua]–This is the countdown–
elseif p3 == true then
timer.cancel(startTmr)
local Go = display.newText(“GO!!!”, (_W/2-100)/3, _H/2-100, “MarkerFelt-Wide”, 200)
Go.xScale = .5; Go.yScale = .5; Go:setTextColor(0,255,0)
transition.to(Go, {time=4000, xScale = 5, yScale = 5, alpha = 0})
Scene:insert(Go)
ready = true
inGameMusicChannel = audio.play(gameMusic, {channel=2})
end
–Then I push restart and this function is called–
local function reset (e)
if ready == true then
audio.stop(inGameMusicChannel)
audio.rewind(inGameMusicChannel)
timer.cancel(countTmr)
timer.cancel(startTmr)
timer.cancel(ptsTmr)
timer.cancel(gameTmr)
timer.cancel(horTmr)
timer.cancel(vertTmr)
Runtime:removeEventListener(“enterFrame”, findVertPos)
Runtime:removeEventListener(“enterFrame”, findHorPos)
Runtime:removeEventListener(“enterFrame”, blueList)
Runtime:removeEventListener(“enterFrame”, redList)
Runtime:removeEventListener(“enterFrame”, greenList)
Runtime:removeEventListener(“enterFrame”, yellowList)
Runtime:removeEventListener(“enterFrame”, silverList)
Runtime:removeEventListener(“enterFrame”, orangeList)
director:changeScene (“easyTransition”)
end
end
local function fade (e)
if ready == true then
audio.rewind(inGameMusicChannel)
audio.fade({channel=0, time=1000, volume=0})
tmr = timer.performWithDelay(1000, reset)
transition.to(Scene, {time=1000, alpha = 0})
end
end
restart:addEventListener(“touch”, fade)[/lua]
Whenever the game loads, the music just starts from where it stopped. It doesn’t rewind. Anybody have a solution?
Much appreciated,
J.K. [import]uid: 66117 topic_id: 18583 reply_id: 318583[/import]
[import]uid: 52491 topic_id: 18583 reply_id: 71375[/import]