I am somewhat lost as to how the LibGDX input processor works and how to implement it for what i want. I simple want to detect if a touch was made or released in a specific class. Something as simple as "if (touchUp) { //do stuff }".
But the input processor works differently, it just runs the code there when a touch is released. The only way i can think of doing what i want feels hacky: create globals in my class and set these to true from the InputProcessor and at the end of the update cycle in my class I put them false again.
//MyInputProcessor
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
MyClass.touched = true;
return false;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
MyClass.released = true;
return false;
}
//MyClass
public static touched = false;
public static released = false;
@Override
public void render(float delta) {
if (touched)
//do stuff
if (released)
//do stuff
//end of update
touched = false;
released = false;
}
It just doesn't feel right to do it this way. If i want to do all the touchup/touchdown code inside the InputProcessor class i have to make tons of fields in MyClass global. Am i missing something? I just need something like "if (getInputProcessor().getTouchDown) { //Do stuff }".
Also, if i want to have multiple pointers for fingers (Which is highly unlikely) the above example does not work.