An odd, cryptic error from libgdx's version of

2019-09-01 10:08发布

问题:

Code

There is my code for my Screen object. The garble of arrays and Vector2s at the bottom is just a long list of models for the cats. My goal is to make a port of http://catsinspace.co.nf, my website, to learn how to use libgdx and its box2d port. I am trying to get the mousejoint working, but I apparently don't understand how a groundBody is supposed to work, despite my hours of googling. Here is my strange, cryptic error that I have tried googling fruitlessly:

AL lib: alc_cleanup: 1 device not closed
Assertion failed!

Program: C:\Program Files\Java\jre7\bin\javaw.exe
File: /var/lib/jenkins/workspace/libgdx/gdx/jni/Box2D/Dynamics/Joints/b2MouseJoint.cpp, Line 125

Expression: d + h * k > 1.19209289550781250000e-7F

It pops up when I try to drag the cat, but I can try to drag the walls without error.

I figured it out. I'm an idiot. The actual body that you want to be dragged needs to be bodyB and not bodyA.

回答1:

def.bodyA = groundBody;
def.bodyB = callback.body;
def.maxForce = 1000f;

This will make it work, though I cannot explain you why...