2
\$\begingroup\$

I implemented GestureListener in my Overlap2dStage to pan the camera when the player drags its finger over the screen. But I also have some actors that extend InputAdapter to detect when the user touches on them. Then I mix them with a InputMultiplexer.

So far it's working fine on my computer, but when I get into Android and tap an object it trigers both: pan() from stage and touchDown() from the actor.

I remember I read something about a pan box to decrease the sensibility, since in a touch screen you are touching several pixels, it detectes a pan. It's worst in smaller screens.

\$\endgroup\$
0
\$\begingroup\$

I guess you are looking for the constructor:

GestureDetector(float halfTapSquareSize, float tapCountInterval, 
        float longPressDuration, float maxFlingDelay, 
        GestureDetector.GestureListener listener) 

The default constructor has this values: halfTapSquareSize=20, tapCountInterval=0.4f, longPressDuration=1.1f, maxFlingDelay=0.15f.

I don't know with which value you need to change to get what you are looking for. But you could play with them.

Another thing, you could return false for the touchDown() event, as this site says:

If you are supporting multi touch, be sure to return false from the more atomic events such as touchDown and TouchUp, so they still get a crack at handling those events.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks I fixed it using: gestureDetector.setTapSquareSize(Gdx.graphics.getDensity()*30) \$\endgroup\$ – Hohenheimsenberg Jul 6 '15 at 20:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.