【发布时间】:2013-12-26 06:30:42
【问题描述】:
我想在我的游戏中加入一个不涉及对象物理的暂停按钮。代码仅包含一些过渡。如何在电晕中进行暂停和恢复选项?
【问题讨论】:
标签: lua coronasdk corona-storyboard
我想在我的游戏中加入一个不涉及对象物理的暂停按钮。代码仅包含一些过渡。如何在电晕中进行暂停和恢复选项?
【问题讨论】:
标签: lua coronasdk corona-storyboard
如果您只是在谈论暂停过渡,那么答案非常简单。
在 lua 文件的顶部添加: 本地游戏暂停 = 假
然后像这样为“所有”过渡添加一个标签:
transition.to(myObject, {time=2000, y = 768, tag = "animationBlock" } )
“标签”可以是任何东西,只要称之为友好的东西......
然后当你想暂停时,只需说 transition.pause("animationBlock")
这会导致您的动画停止。
要暂停“整个”游戏,需要更多代码,但几乎是一样的......
所以使用上面的本地变量然后创建一个函数让我们说“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 (IsGamePaused() == false) then
transition.resume("animationBlock")
else
transition.pause("animationBlock")
end
【讨论】: