xglide
xglide

Reputation: 65

Differentiating touch events from one another

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.

Upvotes: 1

Views: 34

Answers (1)

Maria Abraham
Maria Abraham

Reputation: 51

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

Upvotes: 1

Related Questions