Can I get a simple answer of how to get an Image to appear on a box2d body? I tried making an x and y int for the image and body but once the body moves the image stays static. If you do answer, please explain the code if you could. If you're interested in my full source code, check out my post here: http://www.java-gaming.org/topics/libgdx-drawing-a-sprite-on-to-a-box2d-body/33894/msg/319927/view.html#msg319927
This is what I have been using to do so. Since the bodies position is in the center of it, but the position of the sprite is at the bottom left corner, you need to apply an offset of width/2 and height/2 to the sprite.
public void drawSpriteForBody(Body body, Sprite sprite, SpriteBatch spriteBatch) {
Vector2 offset = new Vector2(sprite.getWidth() / 2f, sprite.getHeight() / 2f);
Vector2 position = body.getPosition().cpy().scl(Constants.PIXELS_PER_METER).sub(offset);
float rotation = body.getAngle() * MathUtils.radiansToDegrees;
sprite.setRotation(rotation);
sprite.setPosition(position.x, position.y);
sprite.draw(spriteBatch);
}