how to add sound in memory game.

Hi everyone, i currently i building a memory game and  I wish add the sound according to the image i had flipped, eg i flipped an apple card then a sound of apple will produces. Unfortunately, i dunno how to do it. Anyone can help? 

--------------------------------------------------------------------------------- -- -- scene1.lua -- --------------------------------------------------------------------------------- local composer = require( "composer" ) local scene = composer.newScene() composer.imgDir = "memoryGame/" composer.audioDir = "audio/" --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- local image,text1,belajar,bermain -- Touch event listener for background image local numPages = 1 -- number of pages in the project local sceneGroup = nil -- main group for all page elements local W = display.contentWidth; -- full width of the page local H = display.contentHeight; -- full height of the page local curPage = 1 -- number of the current page -- Button names local but\_cover1 local but\_cover2 local but\_cover3 local but\_cover4 local but\_cover5 local but\_cover6 local but\_cover7 local but\_cover8 -- Action names local act\_completed -- Variables names local flipped = {} -- holds the flipped cards local flips = 1 -- Holds the number of flips (max 2) local tList = {1,1,2,2,3,3,4,4} -- Holds the number of each card local randList = {} -- Holds the random list of cards in the board local isCompleted = false -- local paired = 0 -- local totPairs = 4 -- math.randomseed(os.time()) -- All layers on a table local layer = {} -- All audio files on a table local allAudios = {} local function homeButtonTouch( self, event ) if event.phase == "began" then composer.gotoScene( "menu", "fade", 400 ) return true end end -- Calculates anchor points local function repositionAnchor( object, newAnchorX, newAnchorY ) local origX = object.x; local origY = object.y if newAnchorX ~= 0.5 or newAnchorY ~= 0.5 then local width = object.width; local height = object.height local xCoord = width \* (newAnchorX - .5) local yCoord = height \* (newAnchorY - .5) object.x = origX + xCoord; object.y = origY + yCoord object.oriX = object.x; object.oriY = object.y end end -- Called when the scene's view does not exist: function scene:create( event ) local sceneGroup = self.view homeButton = display.newImage( "button/homeBtn.png" ) homeButton.x = 1000 homeButton.y = 150 sceneGroup:insert( homeButton ) homeButton.touch = homeButtonTouch print( "\n1: create event") -- BEFORE variables flipped = {} -- holds the flipped cards flips = 1 -- Holds the number of flips (max 2) tList = {1,1,2,2,3,3,4,4} -- Holds the number of each card randList = {} -- Holds the random list of cards in the board isCompleted = false -- paired = 0 -- totPairs = 4 -- -- Capture and set group position local function groupPos(obj) local minX, minY for i = 1, obj.numChildren do local currentRecord = obj[i] if i == 1 then minX = currentRecord.x - currentRecord.contentWidth \* 0.5 minY = currentRecord.y - currentRecord.contentHeight \* 0.5 end local mX = currentRecord.x - currentRecord.contentWidth \* 0.5 if mX \< minX then minX = mX end local mY = currentRecord.y - currentRecord.contentHeight \* 0.5 if mY \< minY then minY = mY end end obj.x = minX + obj.contentWidth \* 0.5 obj.y = minY + obj.contentHeight \* 0.5 end -- Multilingual items -- (TOP) External code will render here -- Shuffle cards while #tList ~= 0 do local ind = math.random(#tList) table.insert(randList, tList[ind]) table.remove(tList,ind) end -- Positions each photo local cards = { {141,300}, {387,300}, {635,300}, {881,300}, {141, 489}, {387,489}, {635,489}, {881,489} } --olds each card position in the table local card = {} -- table to draw each card for i = 1,#randList do card[i] = display.newImageRect( composer.imgDir.. "p1\_photo"..randList[i]..".png", 220, 165 ); card[i].x = cards[i][1] card[i].y = cards[i][2] sceneGroup:insert(card[i]) end for i,v in ipairs(randList) do print(i,v) end -- Layer\_1 positioning layer.Layer\_1 = display.newImage( "background/playbg1.png" ) layer.Layer\_1.x = 515; layer.Layer\_1.y = 385 sceneGroup:insert( 1, layer.Layer\_1); sceneGroup.Layer\_1 = layer.Layer\_1 -- cover1 positioning layer.cover1 = display.newImageRect( composer.imgDir.. "p1\_cover1.png", 220, 165 ); layer.cover1.x = 141; layer.cover1.y = 300; layer.cover1.alpha = 1; layer.cover1.oldAlpha = 1 layer.cover1.oriX = layer.cover1.x; layer.cover1.oriY = layer.cover1.y layer.cover1.oriXs = layer.cover1.xScale; layer.cover1.oriYs = layer.cover1.yScale layer.cover1.name = "cover1" sceneGroup:insert(layer.cover1); sceneGroup.cover1 = layer.cover1 -- cover2 positioning layer.cover2 = display.newImageRect( composer.imgDir.. "p1\_cover1.png", 220, 165 ); layer.cover2.x = 387; layer.cover2.y = 300; layer.cover2.alpha = 1; layer.cover2.oldAlpha = 1 layer.cover2.oriX = layer.cover2.x; layer.cover2.oriY = layer.cover2.y layer.cover2.oriXs = layer.cover2.xScale; layer.cover2.oriYs = layer.cover2.yScale layer.cover2.name = "cover2" sceneGroup:insert(layer.cover2); sceneGroup.cover2 = layer.cover2 -- cover3 positioning layer.cover3 = display.newImageRect( composer.imgDir.. "p1\_cover1.png", 220, 165 ); layer.cover3.x = 635; layer.cover3.y = 300; layer.cover3.alpha = 1; layer.cover3.oldAlpha = 1 layer.cover3.oriX = layer.cover3.x; layer.cover3.oriY = layer.cover3.y layer.cover3.oriXs = layer.cover3.xScale; layer.cover3.oriYs = layer.cover3.yScale layer.cover3.name = "cover3" sceneGroup:insert(layer.cover3); sceneGroup.cover3 = layer.cover3 -- cover4 positioning layer.cover4 = display.newImageRect( composer.imgDir.. "p1\_cover1.png", 220, 165 ); layer.cover4.x = 881; layer.cover4.y = 300; layer.cover4.alpha = 1; layer.cover4.oldAlpha = 1 layer.cover4.oriX = layer.cover4.x; layer.cover4.oriY = layer.cover4.y layer.cover4.oriXs = layer.cover4.xScale; layer.cover4.oriYs = layer.cover4.yScale layer.cover4.name = "cover4" sceneGroup:insert(layer.cover4); sceneGroup.cover4 = layer.cover4 -- cover5 positioning layer.cover5 = display.newImageRect( composer.imgDir.. "p1\_cover1.png", 220, 165 ); layer.cover5.x = 141; layer.cover5.y = 489; layer.cover5.alpha = 1; layer.cover5.oldAlpha = 1 layer.cover5.oriX = layer.cover5.x; layer.cover5.oriY = layer.cover5.y layer.cover5.oriXs = layer.cover5.xScale; layer.cover5.oriYs = layer.cover5.yScale layer.cover5.name = "cover5" sceneGroup:insert(layer.cover5); sceneGroup.cover5 = layer.cover5 -- cover6 positioning layer.cover6 = display.newImageRect( composer.imgDir.. "p1\_cover1.png", 220, 165 ); layer.cover6.x = 387; layer.cover6.y = 489; layer.cover6.alpha = 1; layer.cover6.oldAlpha = 1 layer.cover6.oriX = layer.cover6.x; layer.cover6.oriY = layer.cover6.y layer.cover6.oriXs = layer.cover6.xScale; layer.cover6.oriYs = layer.cover6.yScale layer.cover6.name = "cover6" sceneGroup:insert(layer.cover6); sceneGroup.cover6 = layer.cover6 -- cover7 positioning layer.cover7 = display.newImageRect( composer.imgDir.. "p1\_cover1.png", 220, 165 ); layer.cover7.x = 635; layer.cover7.y = 489; layer.cover7.alpha = 1; layer.cover7.oldAlpha = 1 layer.cover7.oriX = layer.cover7.x; layer.cover7.oriY = layer.cover7.y layer.cover7.oriXs = layer.cover7.xScale; layer.cover7.oriYs = layer.cover7.yScale layer.cover7.name = "cover7" sceneGroup:insert(layer.cover7); sceneGroup.cover7 = layer.cover7 -- cover8 positioning layer.cover8 = display.newImageRect( composer.imgDir.. "p1\_cover1.png", 220, 165 ); layer.cover8.x = 881; layer.cover8.y = 489; layer.cover8.alpha = 1; layer.cover8.oldAlpha = 1 layer.cover8.oriX = layer.cover8.x; layer.cover8.oriY = layer.cover8.y layer.cover8.oriXs = layer.cover8.xScale; layer.cover8.oriYs = layer.cover8.yScale layer.cover8.name = "cover8" sceneGroup:insert(layer.cover8); sceneGroup.cover8 = layer.cover8 -- text positioning layer.text = display.newImageRect( composer.imgDir.. "p1\_text.png", 305, 30 ); layer.text.x = 184; layer.text.y = 150; layer.text.alpha = 1; layer.text.oldAlpha = 1 layer.text.oriX = layer.text.x; layer.text.oriY = layer.text.y layer.text.oriXs = layer.text.xScale; layer.text.oriYs = layer.text.yScale layer.text.name = "text" sceneGroup:insert( layer.text); sceneGroup.text = layer.text end function scene:show( event ) local phase = event.phase if "did" == phase then print( "1: show event, phase did" ) -- remove previous scene's view -- Update Lua memory text display homeButton:addEventListener( "touch", homeButton ) -- Check for previous bookmarks if (tonumber(composer.kBookmark) == 1) then local path = system.pathForFile( "book.txt", system.DocumentsDirectory ) local file = io.open( path, "w+" ) file:write ( curPage.."\n1" ) io.close( file ) end -- Check for for auto play settings if (tonumber(composer.kAutoPlay) \> 0) then local function act\_autoPlay(event) if(curPage \< numPages) then if(composer.kBidi == false) then composer.gotoScene( "page\_"..curPage+1, { effect = "fromRight"} ) else composer.gotoScene( "page\_"..curPage-1, { effect = "fromLeft"} ) end end end composer.timerStash.timer\_AP = timer.performWithDelay( composer.kAutoPlay\*1000, act\_autoPlay, 1 ) end -- Actions (functions) act\_completed = function (event) if (paired == totPairs) then composer.gotoScene(composer.getSceneName( "current" ),{recreate=true}) end end --End Actions (functions) -- Button event listeners local function oncover1Event(event) but\_cover1(layer.cover1) return true end layer.cover1:addEventListener("tap", oncover1Event ) local function oncover2Event(event) but\_cover2(layer.cover2) return true end layer.cover2:addEventListener("tap", oncover2Event ) local function oncover3Event(event) but\_cover3(layer.cover3) return true end layer.cover3:addEventListener("tap", oncover3Event ) local function oncover4Event(event) but\_cover4(layer.cover4) return true end layer.cover4:addEventListener("tap", oncover4Event ) local function oncover5Event(event) but\_cover5(layer.cover5) return true end layer.cover5:addEventListener("tap", oncover5Event ) local function oncover6Event(event) but\_cover6(layer.cover6) return true end layer.cover6:addEventListener("tap", oncover6Event ) local function oncover7Event(event) but\_cover7(layer.cover7) return true end layer.cover7:addEventListener("tap", oncover7Event ) local function oncover8Event(event) but\_cover8(layer.cover8) return true end layer.cover8:addEventListener("tap", oncover8Event ) -- Button functions function but\_cover1(self) --External code --External code print("flips: "..flips) -- verifies number of flips if (flips \< 2) then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) -- blocks tentatives to press the same card if flipped[1] ~= self then --check if the entry is the same as the first one flips = flips + 1; if flips \> 2 then flips = 2 end -- updates the number of flips table.insert(flipped,self) -- updates the content of flipped table end elseif flips == 2 then flips = flips + 1 --; if flips \> 2 then flips = 2 end -- two flips made -- blocks tentatives to press the same card if flipped[1] ~= self then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) table.insert(flipped,self) -- updates the content of flipped table if (randList[tonumber(string.sub(string.reverse(flipped[1].name),1,1))] == randList[tonumber(string.sub(string.reverse(flipped[2].name),1,1))]) then --equal images, move buttons to out of screen flipped[1].x = 5000 flipped[2].x = 5000 flips = 1 -- returns the number of flips to 1 flipped = {} --cleans the flipped table paired = paired + 1 act\_completed() else -- cards don't match local function hideAgain() composer.trans.newTransition\_898 = transition.to( flipped[1], {alpha=1, time=1000, delay=0}) composer.trans.newTransition\_888 = transition.to( flipped[2], {alpha=1, time=1000, delay=0}) local function zeroesFlip() flips = 1 flipped = {} print("flips:"..flips) end composer.timerStash.timer\_fl = timer.performWithDelay( 1000, zeroesFlip, 1 ) --timer to block the cards again, with the cover image end composer.timerStash.timer\_AP = timer.performWithDelay( 2000, hideAgain, 1 ) --timer to block the cards again, with the cover image end end end end function but\_cover2(self) --External code --External code print("flips: "..flips) -- verifies number of flips if (flips \< 2) then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) -- blocks tentatives to press the same card if flipped[1] ~= self then --check if the entry is the same as the first one flips = flips + 1; if flips \> 2 then flips = 2 end -- updates the number of flips table.insert(flipped,self) -- updates the content of flipped table end elseif flips == 2 then flips = flips + 1 --; if flips \> 2 then flips = 2 end -- two flips made -- blocks tentatives to press the same card if flipped[1] ~= self then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) table.insert(flipped,self) -- updates the content of flipped table if (randList[tonumber(string.sub(string.reverse(flipped[1].name),1,1))] == randList[tonumber(string.sub(string.reverse(flipped[2].name),1,1))]) then --equal images, move buttons to out of screen flipped[1].x = 5000 flipped[2].x = 5000 flips = 1 -- returns the number of flips to 1 flipped = {} --cleans the flipped table paired = paired + 1 act\_completed() else -- cards don't match local function hideAgain() composer.trans.newTransition\_898 = transition.to( flipped[1], {alpha=1, time=1000, delay=0}) composer.trans.newTransition\_888 = transition.to( flipped[2], {alpha=1, time=1000, delay=0}) local function zeroesFlip() flips = 1 flipped = {} print("flips:"..flips) end composer.timerStash.timer\_fl = timer.performWithDelay( 1000, zeroesFlip, 1 ) --timer to block the cards again, with the cover image end composer.timerStash.timer\_AP = timer.performWithDelay( 2000, hideAgain, 1 ) --timer to block the cards again, with the cover image end end end end function but\_cover3(self) --External code --External code print("flips: "..flips) -- verifies number of flips if (flips \< 2) then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) -- blocks tentatives to press the same card if flipped[1] ~= self then --check if the entry is the same as the first one flips = flips + 1; if flips \> 2 then flips = 2 end -- updates the number of flips table.insert(flipped,self) -- updates the content of flipped table end elseif flips == 2 then flips = flips + 1 --; if flips \> 2 then flips = 2 end -- two flips made -- blocks tentatives to press the same card if flipped[1] ~= self then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) table.insert(flipped,self) -- updates the content of flipped table if (randList[tonumber(string.sub(string.reverse(flipped[1].name),1,1))] == randList[tonumber(string.sub(string.reverse(flipped[2].name),1,1))]) then --equal images, move buttons to out of screen flipped[1].x = 5000 flipped[2].x = 5000 flips = 1 -- returns the number of flips to 1 flipped = {} --cleans the flipped table paired = paired + 1 act\_completed() else -- cards don't match local function hideAgain() composer.trans.newTransition\_898 = transition.to( flipped[1], {alpha=1, time=1000, delay=0}) composer.trans.newTransition\_888 = transition.to( flipped[2], {alpha=1, time=1000, delay=0}) local function zeroesFlip() flips = 1 flipped = {} print("flips:"..flips) end composer.timerStash.timer\_fl = timer.performWithDelay( 1000, zeroesFlip, 1 ) --timer to block the cards again, with the cover image end composer.timerStash.timer\_AP = timer.performWithDelay( 2000, hideAgain, 1 ) --timer to block the cards again, with the cover image end end end end function but\_cover4(self) --External code --External code print("flips: "..flips) -- verifies number of flips if (flips \< 2) then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) -- blocks tentatives to press the same card if flipped[1] ~= self then --check if the entry is the same as the first one flips = flips + 1; if flips \> 2 then flips = 2 end -- updates the number of flips table.insert(flipped,self) -- updates the content of flipped table end elseif flips == 2 then flips = flips + 1 --; if flips \> 2 then flips = 2 end -- two flips made -- blocks tentatives to press the same card if flipped[1] ~= self then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) table.insert(flipped,self) -- updates the content of flipped table if (randList[tonumber(string.sub(string.reverse(flipped[1].name),1,1))] == randList[tonumber(string.sub(string.reverse(flipped[2].name),1,1))]) then --equal images, move buttons to out of screen flipped[1].x = 5000 flipped[2].x = 5000 flips = 1 -- returns the number of flips to 1 flipped = {} --cleans the flipped table paired = paired + 1 act\_completed() else -- cards don't match local function hideAgain() composer.trans.newTransition\_898 = transition.to( flipped[1], {alpha=1, time=1000, delay=0}) composer.trans.newTransition\_888 = transition.to( flipped[2], {alpha=1, time=1000, delay=0}) local function zeroesFlip() flips = 1 flipped = {} print("flips:"..flips) end composer.timerStash.timer\_fl = timer.performWithDelay( 1000, zeroesFlip, 1 ) --timer to block the cards again, with the cover image end composer.timerStash.timer\_AP = timer.performWithDelay( 2000, hideAgain, 1 ) --timer to block the cards again, with the cover image end end end end function but\_cover5(self) --External code --External code print("flips: "..flips) -- verifies number of flips if (flips \< 2) then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) -- blocks tentatives to press the same card if flipped[1] ~= self then --check if the entry is the same as the first one flips = flips + 1; if flips \> 2 then flips = 2 end -- updates the number of flips table.insert(flipped,self) -- updates the content of flipped table end elseif flips == 2 then flips = flips + 1 --; if flips \> 2 then flips = 2 end -- two flips made -- blocks tentatives to press the same card if flipped[1] ~= self then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) table.insert(flipped,self) -- updates the content of flipped table if (randList[tonumber(string.sub(string.reverse(flipped[1].name),1,1))] == randList[tonumber(string.sub(string.reverse(flipped[2].name),1,1))]) then --equal images, move buttons to out of screen flipped[1].x = 5000 flipped[2].x = 5000 flips = 1 -- returns the number of flips to 1 flipped = {} --cleans the flipped table paired = paired + 1 act\_completed() else -- cards don't match local function hideAgain() composer.trans.newTransition\_898 = transition.to( flipped[1], {alpha=1, time=1000, delay=0}) composer.trans.newTransition\_888 = transition.to( flipped[2], {alpha=1, time=1000, delay=0}) local function zeroesFlip() flips = 1 flipped = {} print("flips:"..flips) end composer.timerStash.timer\_fl = timer.performWithDelay( 1000, zeroesFlip, 1 ) --timer to block the cards again, with the cover image end composer.timerStash.timer\_AP = timer.performWithDelay( 2000, hideAgain, 1 ) --timer to block the cards again, with the cover image end end end end function but\_cover6(self) --External code --External code print("flips: "..flips) -- verifies number of flips if (flips \< 2) then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) -- blocks tentatives to press the same card if flipped[1] ~= self then --check if the entry is the same as the first one flips = flips + 1; if flips \> 2 then flips = 2 end -- updates the number of flips table.insert(flipped,self) -- updates the content of flipped table end elseif flips == 2 then flips = flips + 1 --; if flips \> 2 then flips = 2 end -- two flips made -- blocks tentatives to press the same card if flipped[1] ~= self then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) table.insert(flipped,self) -- updates the content of flipped table if (randList[tonumber(string.sub(string.reverse(flipped[1].name),1,1))] == randList[tonumber(string.sub(string.reverse(flipped[2].name),1,1))]) then --equal images, move buttons to out of screen flipped[1].x = 5000 flipped[2].x = 5000 flips = 1 -- returns the number of flips to 1 flipped = {} --cleans the flipped table paired = paired + 1 act\_completed() else -- cards don't match local function hideAgain() composer.trans.newTransition\_898 = transition.to( flipped[1], {alpha=1, time=1000, delay=0}) composer.trans.newTransition\_888 = transition.to( flipped[2], {alpha=1, time=1000, delay=0}) local function zeroesFlip() flips = 1 flipped = {} print("flips:"..flips) end composer.timerStash.timer\_fl = timer.performWithDelay( 1000, zeroesFlip, 1 ) --timer to block the cards again, with the cover image end composer.timerStash.timer\_AP = timer.performWithDelay( 2000, hideAgain, 1 ) --timer to block the cards again, with the cover image end end end end function but\_cover7(self) --External code --External code print("flips: "..flips) -- verifies number of flips if (flips \< 2) then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) -- blocks tentatives to press the same card if flipped[1] ~= self then --check if the entry is the same as the first one flips = flips + 1; if flips \> 2 then flips = 2 end -- updates the number of flips table.insert(flipped,self) -- updates the content of flipped table end elseif flips == 2 then flips = flips + 1 --; if flips \> 2 then flips = 2 end -- two flips made -- blocks tentatives to press the same card if flipped[1] ~= self then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) table.insert(flipped,self) -- updates the content of flipped table if (randList[tonumber(string.sub(string.reverse(flipped[1].name),1,1))] == randList[tonumber(string.sub(string.reverse(flipped[2].name),1,1))]) then --equal images, move buttons to out of screen flipped[1].x = 5000 flipped[2].x = 5000 flips = 1 -- returns the number of flips to 1 flipped = {} --cleans the flipped table paired = paired + 1 act\_completed() else -- cards don't match local function hideAgain() composer.trans.newTransition\_898 = transition.to( flipped[1], {alpha=1, time=1000, delay=0}) composer.trans.newTransition\_888 = transition.to( flipped[2], {alpha=1, time=1000, delay=0}) local function zeroesFlip() flips = 1 flipped = {} print("flips:"..flips) end composer.timerStash.timer\_fl = timer.performWithDelay( 1000, zeroesFlip, 1 ) --timer to block the cards again, with the cover image end composer.timerStash.timer\_AP = timer.performWithDelay( 2000, hideAgain, 1 ) --timer to block the cards again, with the cover image end end end end function but\_cover8(self) --External code --External code print("flips: "..flips) -- verifies number of flips if (flips \< 2) then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) -- blocks tentatives to press the same card if flipped[1] ~= self then --check if the entry is the same as the first one flips = flips + 1; if flips \> 2 then flips = 2 end -- updates the number of flips table.insert(flipped,self) -- updates the content of flipped table end elseif flips == 2 then flips = flips + 1 --; if flips \> 2 then flips = 2 end -- two flips made -- blocks tentatives to press the same card if flipped[1] ~= self then composer.trans.newTransition\_743 = transition.to( self, {alpha=0, time=1000, delay=0}) table.insert(flipped,self) -- updates the content of flipped table if (randList[tonumber(string.sub(string.reverse(flipped[1].name),1,1))] == randList[tonumber(string.sub(string.reverse(flipped[2].name),1,1))]) then --equal images, move buttons to out of screen flipped[1].x = 5000 flipped[2].x = 5000 flips = 1 -- returns the number of flips to 1 flipped = {} --cleans the flipped table paired = paired + 1 act\_completed() else -- cards don't match local function hideAgain() composer.trans.newTransition\_898 = transition.to( flipped[1], {alpha=1, time=1000, delay=0}) composer.trans.newTransition\_888 = transition.to( flipped[2], {alpha=1, time=1000, delay=0}) local function zeroesFlip() flips = 1 flipped = {} print("flips:"..flips) end composer.timerStash.timer\_fl = timer.performWithDelay( 1000, zeroesFlip, 1 ) --timer to block the cards again, with the cover image end composer.timerStash.timer\_AP = timer.performWithDelay( 2000, hideAgain, 1 ) --timer to block the cards again, with the cover image end end end end -- swipe this page with spacer of 120 in normal direction composer.Gesture.activate( layer.Layer\_1, {swipeLength=120} ) composer.pageSwap = function (event ) local options if event.phase == "ended" and event.direction ~= nil then local wPage = curPage if event.direction == "left" and composer.kBidi == false then wPage = curPage + 1 if wPage \> numPages then wPage = curPage end options = { effect = "fromRight"} elseif event.direction == "left" and composer.kBidi == true then wPage = curPage - 1 if wPage \< 1 then wPage = 1 end options = { effect = "fromLeft"} elseif event.direction == "right" and composer.kBidi == true then wPage = curPage + 1 if wPage \> numPages then wPage = curPage end options = { effect = "fromRight"} elseif event.direction == "right" and composer.kBidi == false then wPage = curPage - 1 if wPage \< 1 then wPage = 1 end options = { effect = "fromLeft"} end if tonumber(wPage) ~= tonumber(curPage) then composer.gotoScene("page\_"..wPage, options) end end end layer.Layer\_1:addEventListener( composer.Gesture.SWIPE\_EVENT, composer.pageSwap ) composer.test = composer.pageSwap -- (BOTTOM) External code will render here end --ends phase did end function scene:hide( event ) local phase = event.phase if "will" == phase then print( "1: hide event, phase will" ) -- remove touch listener for image composer.cancelAllTimers(); layer.Layer\_1:removeEventListener( composer.Gesture.SWIPE\_EVENT, composer.pageSwap ); homeButton:removeEventListener( "touch", homeButton ) elseif event.phase == "did" then composer.test = nil end end function scene:destroy( event ) print( "((destroying scene 1's view))" ) end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene

Hi @chyman-91,

The following tutorial may help you. It shows how to set up a table of sounds which can be played from various scenes, so you could just load your sounds and then look up which specific sound to play (from the table) and play it.

https://coronalabs.com/blog/2013/06/04/tutorial-handling-cross-scene-audio/

Take care,

Brent

Hi @chyman-91,

The following tutorial may help you. It shows how to set up a table of sounds which can be played from various scenes, so you could just load your sounds and then look up which specific sound to play (from the table) and play it.

https://coronalabs.com/blog/2013/06/04/tutorial-handling-cross-scene-audio/

Take care,

Brent