We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone,
I'm pretty new to processing and I have started trying to learn to program simple games por android. I'm trying to use the ketai library to recognise gestures (flick, pinch and rotate). The code compiles and executes correctly but nothing seems to work on my phone. I am following this simple tutorial and using the exact same code he uses in this video:
Here's the code I'm using, extracted from the video. I also tried a fix proposed by a user in the comment section, with no luck:
import ketai.ui.*;
import android.view.MotionEvent;
KetaiGesture gesture;
int rectSize = 100;
float rectAngle;
float rectColor;
void setup(){
rectMode(CENTER);
gesture = new KetaiGesture(this);
}
void draw(){
translate (width/2,height/2);
rotate(rectAngle);
fill(rectColor);
rect(0,0,rectSize,rectSize);
}
void onPinch (float x, float y, float d){
rectSize += d;
}
void onRotate (float x, float y, float angle){
rectAngle += angle;
}
void onFlick (float x, float y, float px, float py, float v){
rectColor = color(random(255), random(255), random(255));
}
public boolean surfaceTouchEvent(MotionEvent event) {
//call to keep mouseX, mouseY, etc updated
super.surfaceTouchEvent(event);
//forward event to class for processing
return gesture.surfaceTouchEvent(event);
}
Does anyone know how to fix this, or any other gesture library that's easy to implement?
Thanks in advance!
Answers
@jabercu=== in this case the motionEvent lass for android is made for you::
https://developer.android.com/reference/android/view/MotionEvent.html
i think i have given here code examples for using that.
Specs of your sys and software please, including processing and Android API target.
Kf
I am running processing 3.2.3 on OS X 10.11.6, trying to run the code on a Meizu PRO5 with flyme 5.1.9 (guess thats the android version as well, but not sure if that answers your question on the API target)
Thank you for your comments
UPDATE: finally made it work. Apparently everything in ketai library works fine and I was handling something wrong in the variables.
@jabercu Can you tell me please how you solved this issue? The metod onFlick doesn't work for me either (however onTap works).