Hey Corona Developers! I am developing a game using Corona SDK, however I want to add a “backgroundMusic” to the “titleview” of my game interface. When the player taps play and transitions to the “gameview” i want the "backgroundMusic to be removed. I can load the backgroundMusic into the titleView but how can it be removed when the player begins playing? Thanks for your input guys!
-- Title View local titleBg local playBtn local creditsBtn local titleView -- Credits View local creditsView -- Main Function function Main() local backgroundMusic = audio.loadStream( "backgroundMusic.wav" ) local backgroundMusicChannel = audio.play( backgroundMusic, { channel=1, loops=-1, fadein=5000 } ) titleBg = display.newImage('titleBg.png') playBtn = display.newImage('playBtn.png', display.contentCenterX + 150, display.contentCenterY + 40) creditsBtn = display.newImage('creditsBtn.png', display.contentCenterX - 220, display.contentCenterY + 40) titleView = display.newGroup(titleBg, playBtn, creditsBtn) startButtonListeners('add') end function startButtonListeners(action) if(action == 'add') then playBtn:addEventListener('tap', showGameView) creditsBtn:addEventListener('tap', showCredits) else playBtn:removeEventListener('tap', showGameView) creditsBtn:removeEventListener('tap', showCredits) end end function showCredits:tap(e) playBtn.isVisible = false creditsBtn.isVisible = false creditsView = display.newImage('creditsView.png') transition.from(creditsView, {time = 300, x = -creditsView.width, onComplete = function() creditsView:addEventListener('tap', hideCredits) creditsView.x = creditsView.x - 0.5 end}) end function hideCredits:tap(e) playBtn.isVisible = true creditsBtn.isVisible = true transition.to(creditsView, {time = 300, x = -creditsView.width, onComplete = function() creditsView:removeEventListener('tap', hideCredits) display.remove(creditsView) creditsView = nil end}) end function showGameView:tap(e) transition.to(titleView, {time = 300, x = -titleView.height, onComplete = function() startButtonListeners('rmv') display.remove(titleView) titleView = nil end}) score = display.newText('0' , 397, 9, native.systemFontBold, 25) score:setTextColor(255, 200, 0) roundText = display.newText('Wave', 180, 80, native.systemFontBold, 50) roundText:setTextColor(255, 0, 0) transition.to( roundText, { delay=2000, alpha=0.0 } ) waveText = display.newText(tostring(wave), 430, 260, native.systemFontBold, 50) waveText:setTextColor(255, 0, 0) transition.from( waveText, { time=1000, delay=1000, x=245, y=170 } ) preparewalkers() end Main ()