I just made my character for the game which is a box2d dynamic body:
public Body createPlayer(){
Body body;
BodyDef def = new BodyDef();
def.type = BodyDef.BodyType.DynamicBody;
def.fixedRotation = true;
def.position.set(position.x, position.y);
body = world.createBody(def);
PolygonShape shape = new PolygonShape();
shape.setAsBox(1, 1);
FixtureDef fixtureDef = new FixtureDef();
fixtureDef.shape = shape;
fixtureDef.density = 0.1f;
body.createFixture(fixtureDef).setUserData(this);
body.setLinearVelocity(20, 0);
shape.dispose();
return(body);
}
Is it possible to add texture or sprite to a body? or I'll just set the sprite position the same as the position of my body? so that it will cover the shape of the body and move like the actual box2d body.