Hi,
I am using Java, Libgdx, box2d
I main class I have created a body and I set player x and y position to 50.
How can I set player x and y position to 100.
I am using Java, Libgdx, box2d
I main class I have created a body and I set player x and y position to 50.
Code:
// main class public class main{ ... private void createPlayer() { BodyDef bdef = new BodyDef(); Body body; FixtureDef fdef = new FixtureDef(); PolygonShape shape = new PolygonShape(); /*** Body - Player ***/ bdef.type = BodyType.DynamicBody; bdef.position.set(50 / PPM, 50 / PPM); bdef.linearVelocity.set(1.5f, 0); body = world.createBody(bdef); ..... } }
How can I set player x and y position to 100.
Code:
//player class public class player{ public player(Body body){ super(body); } .... public void update(){ //get player x position currentX = this.getBody().getPosition().x; //how to change player x and y position to 100? } }
Comment