We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have the following code in my sketch to detect swiping movement on the screen so I can move the game character accordingly:
if(mousePressed){
if(mouseXPrevious != -1) {
xSpeed = mouseX - mouseXPrevious;
}
mouseXPrevious = mouseX;
}
else if(mouseXPrevious != -1){
xSpeed = 0;
mouseXPrevious = -1;
}
The code works and runs just fine on my Moto X Play (android 6.0.1), but when I tested the game on my old HTC One X (running android 4.2.2) it seemed that only half of the presses go through. When it did go through though, the character kept moving along with my finger as long as I held my finger on the screen. On the next touch, again nothing. On another try: It works again.
I've never ran into this problem on my main phone(the Motorola). What could be causing this?
Answers
I created a new sketch just to test this. The whole code is as follows:
This also works perfectly on my Motorola, but on the HTC it registers only half the time when i press on the screen. Is this a problem with Processing or am I missing something?
edit. Tried to work around this by writing the following functions and using the new boolean in draw but it had no effect (this too works perfectly on my newer phone):
Seems like the app just completely misses some of the press events
@Sayid=== not any problem with nexus tablet (6.0) and Xperia Z (5.1) it seems that it is a problem with your "old" device Perhaps you can try to set + your screen sensitivity???
The device's touch screen works just fine anywhere else in the system and doesn't miss any clicks. This happens only in the Processing app.
@Sayid=== In the Motionevent class (android) that Processing wraps each input event (button, touch, mouse...) when it is fired retains a millis() param in order to know what it is: simple tap or click, double tap, long pressed and so on; that means that if your sensitivity settings are not those expected some events cannot be captured.
In the doc from android you can read:::
While the framework tries to deliver consistent streams of motion events to views, it cannot guarantee it. Some events may be dropped or modified by containing views in the application before they are delivered thereby making the stream of events inconsistent. Views should always be prepared to handle ACTION_CANCEL and should tolerate anomalous situations such as receiving a new ACTION_DOWN without first having received an ACTION_UP for the prior gesture.
Okay that must be it. Thank you akenaton!