Question

I want to include a pause button in my game which do not involves physics on the objects.The code only consist of some transitions. How can I do pause and the resume options in corona?

Was it helpful?

Solution

If you are just talking about pausing transitions then the answer is pretty straight forward.

At the top of your lua file add: local gamePaused = false

Then add a tag to "all" of your transitions like a so:

transition.to(myObject, {time=2000, y = 768, tag = "animationBlock" } )

"tag" can be anything just call it something friendly...

Then when you want to pause simply say transition.pause("animationBlock")

that would cause your animations to stop.

To pause an "entire" game it is a little more code but pretty much the same thing...

so use the local var above then create a function lets say "IsGamePaused" :

local function IsGamePaused()
if (gamePaused == true) then return true end
--you can add more stuff here like if (inDialog == true) then return true end
--etc. and so forth that way you have 1 function that can check all sorts of other
--information.
return false
end

the just create a function that can pause or resume using the above function saying something like if:

if (IsGamePaused() == false) then
transition.resume("animationBlock")
else
transition.pause("animationBlock")
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top