A user only touches a body if it touches some of the Fixture contained in that body. This means that you can test each Fixture Body using the testPoit() method:
public class Player { private Body _body; public boolean isPointOnPlayer(float x, float y){ for(Fixture fixture : _body.getFixtureList()) if(fixture.testPoint(x, y)) return true; return false; } }
Then you need to create an InputAdapter as follows:
public class PlayerControl extends InputAdapter { private final Camera _camera; private final Player _player; private final Vector3 _touchPosition; public PlayerControl(Camera camera, Player player) { _camera = camera; _player = player;
And last - configure this processor to listen for input:
public class MyGame extends ApplicationAdapter { @Override public void create () {
Read more about touch processing here.
source share