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!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 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 |
EDIT: Nevermind I figured it out haha.