我真的坚持这个我可以成功地发现碰撞,但我不能让两个身体参与碰撞.
这是我的ContactListener
world.setContactListener(listener);
listener = new ContactListener() {
@Override
public void preSolve(Contact contact, Manifold oldManifold) {
}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {
}
//called when two fixtures cease to touch
@Override
public void endContact(Contact contact) {
Fixture fixtureA = contact.getFixtureA();
Fixture fixtureB = contact.getFixtureB();
Gdx.app.log("beginContact", "between" + fixtureA.toString() + "and" + fixtureB.toString());
}
//called when two fixtures begin to touch
@Override
public void beginContact(Contact contact) {
Fixture fixtureA = contact.getFixtureA();
Fixture fixtureB = contact.getFixtureB();
Gdx.app.log("beginContact", "between" + fixtureA.toString() + "and" + fixtureB.toString());
}
};
这也是我在world.step()行之后直接放入render()的内容
int numContacts = world.getContactCount();
if(numContacts > 0)
{
Gdx.app.log("contact", "start of contact list");
for(Contact contact: world.getContactList())
{
Fixture fixtureA = contact.getFixtureA();
Fixture fixtureB = contact.getFixtureB();
Gdx.app.log("contact", "between" + fixtureA.toString() + "and" + fixtureB.toString());
}
Gdx.app.log("contact", "end of contact list");
}
我极度坚持在解决后解决或预先解决的问题真的很困惑.我跟着iforce2d粘性射弹http://www.iforce2d.net/b2dtut/sticky-projectiles,但我不理解C,在eclipse中工作时我遇到很多语法错误.请有人给我看一个工作碰撞的示例代码,在java碰撞后,机体粘在一起.