OK so I am working on an app with levels and on each there is a pause menu. So once you click the start button the physics start and a pause button appears, the problem im getting is that when the pause menu goes onto the screen, I dont know how to remove it without going to the scene again. Here is the code I have at the moment, also sorry for the indents on it! [code]
local function spawnPause()
local Pause = display.newImage(“pause.png”, 505, 416);
function Pause:touch(e)
if(e.phase == “ended”) then
–Pause Physics
local physics = require “physics”
physics.pause( true );
local back = display.newImage(“back.png”, 30, 200 )
local bg = display.newRect( 20, 20, 840, 420 )
local title = display.newText(“Pause Menu”, 300, 40, native.systemFont, 40 )
bg:setFillColor( 0, 0, 0 )
title:setTextColor( 250, 250, 250 )
–Remove listeners
tri:removeEventListener( “touch”, onTouch );
rect:removeEventListener( “touch”, onTouch );
board:removeEventListener( “touch”, onTouch );
board2:removeEventListener( “touch”, onTouch );
go:removeEventListener( “touch”, physics );
go:removeEventListener( “touch”, spawnPause );
restart:removeEventListener( “touch”, nextScene );
–In Function Inserts
localGroup:insert(bg);
localGroup:insert(title);
localGroup:insert(back);
local removePause = function( event )
if event.phase == “ended” then
end
end
back:addEventListener(“touch”, removePause );
end
return true
end
Pause:addEventListener( “touch”, Pause);
localGroup:insert(Pause);
return true
end
[/code]
As you can see from there, there is a function with nothing in it, i did this because i dont know what to put in it haha. But the remove function has to be inside that function because im putting that on a display object being added by the bigger function.
Thanks. [import]uid: 69054 topic_id: 20037 reply_id: 320037[/import]