I my game on android I would like to let my player collide with an invinsible >object. This collision should be detected, but it shouldnt actually stop the >player.
What you need is a custom ContactListener paired with a Box2D sensor body that it can detect. Your player would also be a Box2D body. Give your two bodies identifier in the form of UserData (e.g. a simple string). You can then check for these UserDatas inside your ContactListener.
Fixture.setUserData(...)
Your ContactListener would implement the Box2D ContactListener and override its methods:
public class MyContactListener implements ContactListener{
@Override
public void beginContact(Contact contact) {
Fixture fa = contact.getFixtureA();
Fixture fb = contact.getFixtureB();
if(fa == null || fb == null) return;
// ...
}
@Override
public void endContact(Contact contact) {
Fixture fa = contact.getFixtureA();
Fixture fb = contact.getFixtureB();
if(fa == null || fb == null) return;
// ...
}
@Override
public void preSolve(Contact contact, Manifold oldManifold) {}
@Override
public void postSolve(Contact contact, ContactImpulse impulse) {}
}
The Box2D body and sensor declarations are left as an exercise for the reader.
A beginner tutorial for Box2D can be found here:
http://rotatingcanvas.com/using-box2d-in-libgdx-game-part-i/