I had the same problem. I fixed this by creating the boolean isDown variable as a field of my GameScreen class. Whenever touchDown appears on my background image , I make the variable isDown true, and when touchUp appears - isDown = false. Thus, touchUp will always be the case. Then, still in my GameScreen, in the rendering method, I check if isDown is true, if so, I check if the touch intersects with my player:
if (isDown) { if (pointIntersection(myActor, Gdx.input.getX(), Gdx.input.getY())) { // do something } } else { // reverse the effect of what you did when isDown was true }
where is the pointIntersection method:
public static boolean pointIntersection(Image img, float x, float y) { y = Gdx.graphics.getHeight() - y; if (img.x <= x && img.y <= y && img.x + img.width >= x && img.y + img.height >= y) return true; return false; }
This is the only workaround I have found. However, this is not very pretty, but it works for me.
source share