0
\$\begingroup\$

I have a function I run inside the touchUp method but when I click with the mouse during emulation, it triggers my function multiple times. I don't think its an error with the called method itself because if I put the call in KeyUp then it triggers once as expected.

If it matters I am working in android studio.

\$\endgroup\$
  • 1
    \$\begingroup\$ Try to return true after your function call \$\endgroup\$ – Arda Kara Aug 18 '15 at 10:19
1
\$\begingroup\$

If you use polling, use Gdx.input.justTouched() rather than Gdx.input.isTouched().

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

Have you implemented the other methods in InputProcessor?
It seems to me that your touchUp method is called multiple times because perhaps your touchDown and touchDragged are never called correctly.
Be sure to return false in the unused methods if you don't want to use them.
Perhaps you could show us your code snippet.

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

I will presume you are using InputListener class. Because Input class don't have a touchUp method. You didn't mention this part in your question.

I'll assure you touchUp funciton will not be called twice. You are using an emulator, and in this case touch up function will be triggered by the mouse button. So as long as there is not a second mouse pointer(?), touchUp function is called once per click.

I also will presume you are using only one Listener.

What is happening is touchUp function is not the only function triggered by a mouse click. If you change the position of the mouse while holding it, touchDragged function will also be called. Maybe that's what is confusing you.

Try to put a System.out.println("TOUCH UP"); into your touchUp function to be sure of how many times that function is called. And please don't put it in anywhere else.

If your problem insists on happening, please provide us with more information, so we could help you.

\$\endgroup\$

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.