Corona SDK完全摧毁物理联合

时间:2014-09-13 13:57:05

标签: lua corona physics

我正在Corona sdk制作一个游戏,不同的球弹起并用焊接接头相互粘连。当我重置游戏玩法时,所有关节都被摧毁,然后所有的球被重新定位。以下是我的一些代码:

--stickJoints and balls are tables that contain all the weld joints and ball objects
resetTotal = function()
    for i=1,#stickJoints do
        stickJoints[i]:removeSelf()
        stickJoints[i]=nil
    end
    for i=1,20 do
        --this resets all balls and sets linear and angular velocity to 0
        resetP(balls[i],1000+(i-1)*400,5000,0)
    end
end

问题是,只要点击重置按钮,连接的球就会暂时相互作用。任何想法都有帮助。谢谢!

1 个答案:

答案 0 :(得分:1)

我认为你最好的选择是

  1. 使用timer.performWithDelay调用一个函数,该函数将在物理有机会破坏约束后重新定位球。
  2. 从物理学中移除每个球,并使用延迟函数cal(参见第1项)在重新定位后重新添加它们。