1

So I'm developing a game (played vertically) on the android and I'm wondering how to process certain touch events.

So first, we want our player character to always be moving towards the finger while it is down on the screen, we'll call it the movement action.

Second, we have a function that does something when the screen is briefly tapped, call it the screen action

What should I do to distinguish the two events? I was thinking to time the ACTION_DOWN and ACTION_UP and process the screen action, but a friend said it was a bit hacky and didn't like it. Additionally, I don't want the character to move towards wherever the screen action was made. Is there a way to make these events sort of independent of each other?

Note: the screen action should be able to happen while the movement action is going on.

xglide
  • 55
  • 1
  • 7

1 Answers1

1

I suppose what you need is differentiating between long press and tap. Android already has methods of handling these events. Hope this helps.

Community
  • 1
  • 1
  • does the long press include movement during the long press? – xglide Aug 11 '15 at 06:33
  • If detecting the motion along with longpress is what you want, you can go for onTouch listeners. I found [this](http://stackoverflow.com/questions/7919865/detecting-a-long-press-with-android) interesting. – Maria Abraham Aug 11 '15 at 07:22