Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // sprite.setPosition(body.getPosition().x - sprite.getWidth() / 2, body.getPosition().y - sprite.getHeight() / 2);
- // you have to draw sprites like this for bodies which shape are positioned like this:
- // shape.setPosition(new Vector2(0, 1));
- // obviously the sprite is in the correct place but the shape is not then
- // the shape was a CircleShape with a radius of .5f
- // so the image was drawn right under it, rotating around it
- // however, I'm keeping this formula I figured out to be working in this case.
- // I doubt it works with different shape positions/sizes though
- sprite.setPosition(body.getPosition().x - sprite.getWidth() + sprite.getWidth() / 2 * (1 - MathUtils.sin(body.getAngle()) * 2), body.getPosition().y - sprite.getHeight() / 2 * (1 - MathUtils.cos(body.getAngle()) * 2));
- sprite.setRotation(body.getAngle() * MathUtils.radDeg);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement