【问题标题】:Error when destroying a joint破坏关节时出错
【发布时间】:2013-08-08 05:55:23
【问题描述】:

我正在使用带有 Box2D 的 Libgdx。

当特定身体在地面上坠毁时,我无法破坏关节, 检测到碰撞体,然后我想破坏一些关节。 当我这样做时,总是会出错。

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

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

我正在使用 R.U.B.E.对于 Box2d 的事情。

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

  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

谁能帮帮我? :)

【问题讨论】:

  • 请提及文件 C:\Users\Jake\Downloads\AndroidDevelopment\EclipseDaten\Motor-race-desktop\hs_err_pid5868.log 中存在的错误

标签: box2d libgdx destroy


【解决方案1】:

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

例如

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

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-14
    • 1970-01-01
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 2021-02-02
    • 2013-11-13
    • 1970-01-01
    相关资源
    最近更新 更多