私はこれに本当にこだわっています。衝突を正常に検出できますが、衝突に関与する2つのボディをくっつけることができません。
ここに私の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で衝突した後に体がくっつく作業中の衝突のサンプルコードを誰かに見せてください。