I'm a beginner with java and libgdx, and i'm trying to make a simple sprite of a rectangle slowly going out/in of the screen when I swipe (with GestureDetector). Is there any tool with libgdx to do a simple task like that?
Here the code I have without any animation :
private Sprite rect;
private void drawRect(){
//some code to draw the rectangle as a sprite on a SpriteBatch
// (the rectangle's position is a the top right of the screen)
}
@Override
public boolean fling(float velocityX, float velocityY, int button) {
//swipe right to close
if (velocityX >= 150 && !rectClosed) {
rect.setPosition(rect.getX() + rectWidth, rect.getY());
rectClosed = true;
}
//swipe left to open
if (velocityX <= -150 && rectClosed) {
rect.setPosition(xRectOrigine, rect.getY());
rectClosed = false;
}
return false;
}
Thank you !