I have this code to get pan touch inside an Image and it works fine, but when I uncomment this line

img.setPosition(100, 100);

it doesn't work anymore, why?

Texture tex = new Texture(Gdx.files.internal("square.png"));
        final Image img = new Image(tex);
        //img.setPosition(100, 100);

        img.addListener( new ActorGestureListener(){

            public void pan(InputEvent event, float x, float y, float deltaX, float deltaY) {
                super.pan(event, x, y, deltaX, deltaY);

                int minX = (int)img.getX();
                int maxX = (int)img.getX()+(int)img.getWidth();
                int minY = (int)img.getY();
                int maxY = (int)img.getY()+(int)img.getHeight();

                if ((x>minX && x<maxX)&&(y>minY && y<maxY)){


  • \$\begingroup\$ How does it not work? Does the pan event not fire or does the if-statement always evaluate to false? \$\endgroup\$ – bornander Jan 21 '16 at 15:09
  • \$\begingroup\$ pan event doesn't work, do not consider the if statement \$\endgroup\$ – cyclingIsBetter Jan 21 '16 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.