Ok, I’m following a video tutorial and I have an issue. The idea is that when you click the button 5 times the soundtrack should stop but it doesn’t. I checked my code with the one in the video so many times, I can’t find a difference. This is how it looks:
local \_W = display.viewableContentWidth local \_H = display.viewableContentHeight local c = 0 display.setDefault("background", 1,1,1) local pop\_sound = audio.loadSound("pop.mp3") local soundtrack = audio.loadStream("ring.mp3") local btn = display.newImageRect("btn.png", 250, 125) btn.x = \_W/2 btn.y = \_H/2 local function btntouch(e) if(e.phase == "ended") then c = c + 1 audio.play(pop\_sound) if(c == 5) then audio.stop(soundtrack) end end end btn:addEventListener("touch", btntouch) audio.play(soundtrack, {loops = -1})
if needed I will post a link to the video.
Thanks.