2

我正在使用带有 Box2D 的 Libgdx。

当一个特定的身体在地面上碰撞时,我有一个破坏关节的问题,碰撞的身体被检测到,然后我想破坏一些关节。总是当我这样做时,我会得到一个错误。

我还单独测试了destroy方法进行测试,我得到了同样的错误。它在 world.step(...) 之后被调用,对吗?

我读到了当关节在时间步之间被破坏时会发生错误的事情,但是我怎么能在 world.step 之外做到这一点?

我正在为 Box2d 使用 RUBE。

这是一些即时测试的代码:

  scene.world.step(1.0f/scene.stepsPerSecond, scene.velocityIterations, scene.positionIterations);


          if(!scene.world.isLocked()){      //to check that the joint is no locked

         Joint joint1= scene.get(Joint.class, "joint1");   // read the joint from RUBE scene
         scene.world.destroyJoint(joint1);                   //destroy it


         }

这是错误:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006559368f, pid=5868, tid=3772
#
# JRE version: 7.0_07-b10
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.3-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [gdx64.dll+0x1368f]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Jake\Downloads\AndroidDevelopment\EclipseDaten\Motor-race-desktop\hs_err_pid5868.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
AL lib: alc_cleanup: 1 device not closed

谁能帮我?:)

4

1 回答 1

2

确保正确销毁关节的最佳方法是参考需要销毁的关节,然后在 world.step() 函数之后销毁关节。

例如

world.step(......);
 if(jointToDestroy != null) {
   world.destroyJoint(jointToDestroy); 
   jointToDestroy = null;
 }

希望能帮助到你。

于 2013-08-08T06:34:55.863 回答