Check whether screen is being touched at a given time?

Started by neo187, January 27, 2012, 01:00:59 AM

Previous topic - Next topic

neo187

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

Vi_O

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...

neo187

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!