我已在屏幕中央使用libgdx显示了一张图片。如果我向左滑动,图片应该向左移动;如果我向右滑动,图片应该向右移动。后续的左滑动作也应使图片向左移动,右滑动同理。我使用了GestureListener。在某种程度上,它能正常工作——如果我首先向左滑动,图片会向左移动。但之后,如果我尝试向右滑动,图片仍然会向左移动。那么,在libgdx中,我该如何解决这个问题呢?
class MyGestureListener implements GestureListener {
@Override
public boolean fling(float arg0, float arg1, int arg2) {
// TODO Auto-generated method stub
if(arg0>0)
iX += 20;
else
// else if(arg0*100>iX)
iX-=20;
System.out.println("Hello..............."+iX);
return true;
}
Gdx.input.setInputProcessor(new GestureDetector(0.0f, 0.0f,0.0f, 5f,new MyGestureListener()));
batch.draw(splashTexture, iX, iY);