# Seeking Advice: Collision with JBox2d for Top-Down or Isometric Maps

I Hope I can make this as clear as possible!

Currently working on an action RPG game, very early stages, more just the basic ideas down and written in. So i'll start on with my setup:

Using Java with LibGDX Map creation is done with TILEd Style of map: Isometric

Collision Engine? ... well this is where I need a bit of guidance and advice.

LibGdx is linked in with Box2d which makes it . I'd personally love to use Box2D, more because I've played around with it on a platform level and I liked how it operated with force and impulses etc, however, it seems to be created for only platform style games. So I guess one questions is: Can Box2d's properties be easily changed to support a Top-Down collision system or an Isometric collision system?

I have tried to implement Box2d into a top down game before by setting the gravity to zero, but with no gravity, the other entities on the map just float. (You bump into them and they just start... floating!)

What I was originally thinking was once I have my map created in TILEd, I would start adding a collision layer (Or modify the tiles individually) to mark what is passable and what is not. I have seen examples for box2d (again Platform only however) ways to create an Object in TILEd to mark the collidable wall or floor and when loaded it would create the shapes. Box2d would be perfect if it wasn't for the whole floating entity due to zero gravity.

So what I am looking for...

1) Is there a way to create Box2D work on a Top-Down set up without entities floating?

2) If not, what other solutions do I have for collision?

If there is any other information needed for a better response Please let me know!

Thank you!

it's quite easy to detect collusion in Box2d but you have to know that collusion depend on your Game object or characters which are created with box2d properties ( the BodyDef , FixtureDef..) so all your objects needs to be inside the box2d then in your Main Class you just have to add implements ContactListener if you are using eclipse the compiler will suggest you to override 4 methods beginContact(Contact contact) ndContact(Contact contact) theses two methods will detect all collusion happens in your physical world so if for exemple you try System.out.println(contact); in the beginContact overridden method it will display the address of every object when starts to be in contact with another , and if you want to detect the collusion between a specific object and the world you do like so :

public void beginContact(Contact contact) {

String result = (String) contact.getFixtureA().getBody().getFixtureList().getUserData();
if (result == "Playron")
hud.tick();

}


-

getBody().getFixtureList().getUserData()


this code will look for body fixture which start being in contact with other objects in the word and I'm using getUserData to figure out which of my game characters is the listener and then if the game character is the Playron hub.tick which will decrease the health of the player

here is the Player Class

public Player(World world)
{

BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyType.DYNAMIC;
bodyDef.fixedRotation = true;
bodyDef.position.set(20.0f/RATE, 375.0f/RATE);
characBody = world.createBody(bodyDef);

PolygonShape box = new PolygonShape();
box.setAsBox(10.0f/RATE, 25.0f/RATE);

FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = box;
fixtureDef.density = 2.0f;
fixtureDef.friction = 0.3f;
characBody.createFixture(fixtureDef);
characBody.getFixtureList().setUserData("Playron");

}


i hope this clarifies your concern