What is the difference between isTouched and justTouched?

Fortunately, it did not take long to figure this out, but as a beginning java programmer using libGDX, I couldn’t quite figure out the difference between isTouched and justTouched right off the bat. A Google search actually told me the answer, but at the time I did not understand what that answer meant, or when you might use them.

So, to dumb it down for simple folks like me:

  • justTouched – When used in a render method, it will only count the first time you touch the screen, like a “touch down”, but does not render “holding down” the screen. It also does not care about “touch up” or releasing the screen. You might use this to tap an object that you want to register the tap, but do not want it to continue registering that you are holding it. This could be useful to pop a balloon in a game, tap a button, click on something, etc.
  • isTouched – When used in a render method, it will continuously count that you are touching the screen until you let go. This allows you to “hold down” on the screen. Some examples that I could think of for use might be drawing with a paintbrush, turning a page, a button that must be held down, pushing a rock uphill, etc.

Both of these tools have their places, and I could see reasons to implement one or the other depending on your needs. Hopefully that helps someone else out there.

Linux – keep it simple.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s