Touch screen event

I want to put a max touch to the screen when the user touches it . If the user touches the screen 10 times then they have to go to a scene to watch a add to continue playing or pay to continue playing but I am having trouble with that . When I touch the screen 10 times it doesn’t do anything . Any help ?

function touchScreen( event ) if ( event.numTouch == 10 ) then storyboard.gotoScene("maxtap", "fade", 400) else return true end end function onBallTap( event ) storyboard.gotoScene("restart", "fade", 400) return true end function scene:enterScene(event) storyboard.purgeScene("restart") storyboard.removeScene("maxtap.lua") Runtime:addEventListener( "touch", touchScreen ) end function scene:exitScene(event) Ball:removeEventListener( "tap", onBallTap ) Runtime:aremoveEventListener( "touch", touchScreen ) end function scene:destroyScene(event) end scene:addEventListener("createScene", scene) scene:addEventListener("enterScene", scene) scene:addEventListener("exitScene", scene) scene:addEventListener("destroyScene", scene) return scene

At the top create a local attribute call it touch number(or what ever you want)

local numberOfTouch = 0

–later

local function touchScreen(event)

if event.phase == “began” then
numberOfTouch = numberOfTouch+1
end

if ( numberOfTouch == 10 ) then
storyboard.gotoScene(“maxtap”, “fade”, 400)
end

end

Also if you are using are trying to use to storyboard with the lastest version make sure you grab storyboard from github. If this is a new project I recommend using composer over storyboard. Also it is:

Runtime:removeEventListener( “touch”, touchScreen )

I am typing from my phone sorry, I did not use the code editor

At the top create a local attribute call it touch number(or what ever you want)

local numberOfTouch = 0

–later

local function touchScreen(event)

if event.phase == “began” then
numberOfTouch = numberOfTouch+1
end

if ( numberOfTouch == 10 ) then
storyboard.gotoScene(“maxtap”, “fade”, 400)
end

end

Also if you are using are trying to use to storyboard with the lastest version make sure you grab storyboard from github. If this is a new project I recommend using composer over storyboard. Also it is:

Runtime:removeEventListener( “touch”, touchScreen )

I am typing from my phone sorry, I did not use the code editor