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.setSize(157,45);
img.setColor(0,0,0,1f);
img.addListener( new ActorGestureListener(){
@Override
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)){
Utils.print("PAN");
}
}
});
stage.addActor(img);