如何暂停科罗纳的游戏场景



我想在游戏中加入一个暂停按钮,它不涉及对象的物理。代码只包含一些转换。如何在corona中进行暂停和恢复选项?

如果您只是在谈论暂停转换,那么答案是非常直接的。

在您的lua文件顶部添加:本地游戏Paused=错误

然后在"所有"转换中添加一个标签,如so:

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

"标签"可以是任何东西,只要称之为友好的东西。。。

然后,当你想暂停时,简单地说transition.pause("animationBlock")

这会导致你的动画停止。

要暂停"整个"游戏,需要多一点代码,但几乎是一样的。。。

所以使用上面的本地var,然后创建一个函数,比如"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

只需创建一个可以暂停或恢复的函数,使用上面的函数,比如if:

if (IsGamePaused() == false) then
transition.resume("animationBlock")
else
transition.pause("animationBlock")
end

最新更新