Reputation: 187
I have been detecting different kinds of input with the different implemented Gesture Detector methods. I do however want to change some of the preferences of the G.D by changing the parameters of the method below:
public GestureDetector(float halfTapSquareSize,
float tapCountInterval,
float longPressDuration,
float maxFlingDelay,
GestureDetector.GestureListener listener)
I got ^ code of http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/input/GestureDetector.html
I am especially interested in changing the value of "halfTapSquareSize"
How would I go about implementing that into my code below?
public class MyGdxGame extends ApplicationAdapter implements GestureDetector.GestureListener {
@Override
public void create() {
super.create();
//Doing stuff at create
}
@Override
public void resize(int width, int height) {
super.resize(width, height);
}
@Override
public void render() {
super.render();
//Rendering stuff
}
@Override
public void pause() {
}
@Override
public void resume() {
}
@Override
public void dispose() {
//disposing stufff
}
@Override
public boolean touchDown(float x, float y, int pointer, int button) {
return false;
}
@Override
public boolean tap(float x, float y, int count, int button) {
// Doing stuff at tap
return true;
}
@Override
public boolean longPress(float x, float y) {
return false;
}
@Override
public boolean fling(float velocityX, float velocityY, int button) {
return false;
}
@Override
public boolean pan(float x, float y, float deltaX, float deltaY) {
//Doing stuff when paning
}
@Override
public boolean panStop(float x, float y, int pointer, int button) {
return false;
}
@Override
public boolean zoom(float initialDistance, float distance) {
return false;
}
@Override
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) {
return false;
}
}
Upvotes: 0
Views: 201
Reputation: 356
Your code only implements the GestureListener. This listener needs to be associated with a GestureDetector, and the GestureDetector then needs to be registered to handle input.
So within your MyGdxGame class, you'll need something like this:-
GestureDetector input = new GestureDetector(this); // 'this' refers to your MyGdxGame instance
Gdx.input.setInputProcessor(input);
Now you can either supply extra arguments to GestureDetector's constructor, as you have mentioned in your post, or use the GestureDetector's relevant methods, like so:
input.setTapSquareSize(someFloatValue);
Upvotes: 1