Here is what I have done for my game to pause when I double tap on the screen to pause the game:
[code]
local function pause (event)
–check for double tap
if 2 == event.numTaps then
–STOP STUFF
–stop the move function (specific for my game)
Runtime:removeEventListener( “enterFrame”, move );
–disable physics body
myImage.isBodyActive=false
–disable drag for a movieclip
myMovieClip:setDrag{
drag=false
}
–disable a function that gives some extra points
star:removeEventListener(“touch”, starPoint)
–disable pause function so that you can’t pause when already paused
Runtime:removeEventListener(“tap”, pause)
local pausetext = display.newText(“PAUSED”, 0, 0, native.systemFontBold, 50)
pausetext.x=displayX/2
pausetext.y=displayY/2
local resumebutton = display.newImage(“buttons/resumeButton.png”)
resumebutton.x = pausetext.x
resumebutton.y = pausetext.y + 100
–RESUME
local function resume (event)
if event.phase == “ended” then
–hide text and resumebutton
pausetext.isVisible = false
resumebutton.isVisible = false
–START STUFF
–start the move function (specific for my game)
Runtime:addEventListener( “enterFrame”, move );
–enable physics body
myImage.isBodyActive=true
–enable drag for movieclip
myMovieclip:setDrag{
drag=true
}
–enable a function that gives some extra points
star:addEventListener(“touch”, starPoint)
–enable pause function so that you can pause again
Runtime:addEventListener(“tap”, pause)
end
end
–add a event listener to the resumebutton so that the resume function starts when pressed
resumebutton:addEventListener(“touch”, resume)
end
end
– add the eventlistener for tap anywhere on the screen
Runtime:addEventListener(“tap”, pause)
[/code] [import]uid: 24111 topic_id: 8080 reply_id: 308080[/import]