有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

一个矩形精灵的java简单动画

我是java和libgdx的初学者,当我滑动(使用GestureDetector)时,我正在尝试制作一个简单的矩形精灵,它在屏幕上慢慢进出。 有没有libgdx工具可以完成这样的简单任务

下面是我没有任何动画的代码:

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;
}

谢谢!


共 (0) 个答案