Author Topic: Check whether screen is being touched at a given time?  (Read 1462 times)

Offline neo187

  • int
  • **
  • Posts: 73
    • View Profile
Check whether screen is being touched at a given time?
« on: January 27, 2012, 01:00:59 am »
Hi all

This is not strictly a JPCT query but rather an Android programming one....but I can't seem to find any info on this and maybe someone has come across this same issue.

I am currently using onToucheEvent to register all kinds of touch inputs... In my game I am using both ACTION_DOWN and ACTION_UP to trigger certain events....

Sometimes a frame rate  drop can lead the application to not detect an ACTION_UP event following and ACTION_DOWN, so for actions where holding down a button and then releasing it make stuff happen this becomes problematic...

Is there a way to get round this issue? Basically a way to check at any time whether there is a finger on the screen or not, so as to make up for lost touch.up events?

Thank you very much

Offline Vi_O

  • byte
  • *
  • Posts: 17
    • View Profile
Re: Check whether screen is being touched at a given time?
« Reply #1 on: January 27, 2012, 10:48:29 am »
First, check that your OntouchEvent() always return true or it will only get the ACTION_DOWN event.

If it's not this, the problem is that ActionEvents only fire when there is a change. (You can't check a NO_ACTION event then)
So maybe you could use a Timer...

Offline neo187

  • int
  • **
  • Posts: 73
    • View Profile
Re: Check whether screen is being touched at a given time?
« Reply #2 on: January 31, 2012, 01:15:12 pm »
Thanks Vi_O! That seems to have done the trick actually! I needed to have a statement for ACTION_CANCEL which I didn't and I needed to make sure to always return true.... Following the HelloWorld template I was actually returning super.onToucheEvent... Now at a slow framerate the ACTION_UP may register with a bit of a delay but from a small test it seems to always register.

Thanks again!