Popup and physics?

Hello i used popup to make an pause menu, everything works fine so that i can pause the game get the popup up and pause the physics, but i don't know how to unpause the physics then i am in my popup to return to the game?

because is local in my level.lua so can't reach it from my popup.

Anyone know how to solve this?

Kind regards

physics.start() and set gravity on resume.

Hey Peach!

Thanks for the answer! What do you mean by setting gravity on resume?

1
physics.setGravity(0,5,0)

Got it resuming, however, i have some strange behavior, upon clicking resume to close the popup and resume the game it seems like i am clicking on booth the resume and the button that lies under everything and covers the entire screen(i use this button so the user can click anywhere on the screen and not on a certain button).so my ship goes up then the game resumes. Is there another way to make the screen clickable? like a big button? so the user don't have to hit the right button?

It feels strange that then i click the popup and close it then the underlying button also gets clicked?

Here the function for the popup and the underlying button

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--movement of the ship
function ufoMovement(event)
        
        
        --An if that controls what happens then user hit anywhere on the screen and it goes up
        if(event.target.name == "up" and crashed == false)  then
        
                        --An if that fires an timer then touch began
                        if(event.phase == "began") then
 
                                                tmrUp = timer.performWithDelay(150, engines, 0)
 
        
                        --An elseif that checks then user stops to touch the button
                        elseif(event.phase == "ended") then
                                        timer.cancel(tmrUp)
 
                                        
                                        spriteInstance.linearDamping = 0
                                        
                                        --An elseif that checks if ufo has crashed then makes spriteInstance the crashedPos
                        elseif(crashed == true) then
                        
                                spriteInstance.x = crashedPos
 
                        end
        
        end
 
end
 
buttonUp:addEventListener("touch", ufoMovement)
 
--function for open the popup and pausing the physics
function pauseGame(event)
        
        if(event.target.name == "pause")then
                
                physics.pause()
                director:openPopUp("options", closed)
        end
        
end
 
pause:addEventListener("touch", pauseGame)
 
        --function for closing the popup and start physics
        function menuTouch(event)
        
                                --An if that fires an timer then touch began
                                if(event.phase == "began") then
 
                                        director:closePopUp()
                                        physics.start()
                                        physics.setGravity(0,5,0)
 
                                end
        
                
        
        end
 
 
options:addEventListener("touch", menuTouch)
views:991 update:2011/10/25 9:10:48
corona forums © 2003-2011