当场景开始时,Corona SDK 可以延迟一个 enterFrame 函数。

我在我的游戏中有多个场景,在其中一个场景中,物理球被称为“游戏”组中的所有其他对象所跟随移动。

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 秒才执行此函数。我该怎么做?

点赞
用户2211874
用户2211874

请查看这里,这是 Corona 的 timer.performWithDelay() 函数。

2013-12-29 18:42:12
用户1979583
用户1979583
局部函数 `loop(event)`
   ...
   ...
end

局部函数 `triggerListener()`
  Runtime:addEventListener("enterFrame", loop)
end
timer.performWithDaelay(1000,triggerListener,1) -- 参数: 时间(毫秒),函数,循环

继续撰写代码吧................. :)

2013-12-30 04:13:30