Corona 碰撞事件处理程序和关节解决方法

发布于 2024-12-03 12:38:34 字数 301 浏览 2 评论 0原文

我是 Corona 的新手,并且正在尝试将身体移动到路径上以到达某个物体“例如苹果 4 示例”,在它到达该物体后,我想创建一个关节,以便两者作为单个物体移动。

问题是我正在使用碰撞检测来检测移动的物体是否到达物体,一旦检测到碰撞,物体和物体必须连接在一起,所以我创建一个新的关节。但这似乎不起作用。

在Physics.newJoint() API中,有人指出它不应该与碰撞事件Hnadler一起使用。有人知道这是为什么吗?它与某些物理有关还是一个问题或错误?

我尝试解决它,但没有使用物理,所以如果有人知道如何仍然使用物理解决它,请告诉我。

I am new to corona , and am trying to move a body over a path to reach some object "say an apple 4 example" , after it reaches the object i want to create a joint so that both move as a single object.

the problem is that i am using collision detection to detect that the moving body reaches the object , once a collision is detected the object and the body must be joined together , so i create a new joint . but this does not seem to work.

in the physics.newJoint() API it is remarked that it should not be used with the collision eventHnadler . deos anybody have an idea why is that ?? is it related to some physics or it is an issue or a bug ??

i tried to work it around but not using physics , so if anyone has an idea of how to work it around still with physics plz tell me .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趁微风不噪 2024-12-10 12:38:34

因为在碰撞期间更改有关物理模型的任何内容都会干扰当前物理迭代的物理计算,因此它会引发并发修改断言 - 这些对象在计算碰撞期间应如何进行物理响应时被锁定。该框架或子框架。它必须等到计算完成,否则就会因为干扰而被打屁股。

在碰撞事件处理程序中修改物理的所有情况的解决方法是在处理程序中添加 timer.performWithDelay(1, whatYouWannaDo, 1)。这会使其等待,直到程序退出事件处理程序,然后执行 whatYouWannaDo

Because changing anything about the physics model(s) during collision would interfere with the physics calculations for the current physics iteration, it throws a concurrent modification assertion - those objects are locked while they're figuring out how they're supposed to physically respond during that frame or sub-frame. It has to wait until the calculations are done or it gets spanked for interfering.

Workaround in ALL cases of modifying physics in the case of collision event handler is to add timer.performWithDelay(1, whatYouWannaDo, 1) within the handler. This makes it wait until the program exits the event handler and then execute whatYouWannaDo.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文