我的游戏中有多个场景,在其中一个场景中,物理球后面跟着移动称为“游戏”的组中的所有其他对象。
local function loop(event)
local targetx = 600 -ball.x
if targetx>2550 then
targetx = 2550
elseif targetx < display.contentWidth - 1451 then
targetx = display.contentWidth-1451
end
game.x = game.x + ((targetx - game.x) *0.2)
end
Runtime:addEventListener("enterFrame", loop)
这可能并不重要,因为我所需要的只是这个函数在进入场景后 1 秒后才发生。我该怎么做?
最佳答案
这样做:
local function loop(event)
...
...
end
local function triggerListener()
Runtime:addEventListener("enterFrame", loop)
end
timer.performWithDaelay(1000,triggerListener,1) -- Params: time in mS,function,loop
继续编码......................:)
关于lua - Corona sdk 在场景开始时延迟 EnterFrame 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20828659/