我是这样实现的http://prntscr.com/4k6vze 但是我的主要问题是如果我在屏幕上拖动图片不能顺利改变。 我画这样的状态是如何检测左或右移动。
int before=state-1;
if(before>-1)
batcher.draw(text.get(before), 16,200, 64, 64);
batcher.draw(text.get(state), 96, 200,128, 128);
int after=state+1;
if(after<3)
batcher.draw(text.get(after), 240, 200, 64, 64);
batcher.draw(Assets.arrow,320, 32, -64, 64);
batcher.end();
第二个问题是如果我想改变图片我必须弄清楚(更改图片意味着如果做一个平移左边意味着高速公路在高速公路和高速公路的位置在洞穴上的位置?):
public class SimpleDirectionGestureDetector extends GestureDetector {
public interface DirectionListener {
void onLeft();
void onRight();
void onUp();
void onDown();
}
public SimpleDirectionGestureDetector(DirectionListener directionListener) {
super(new DirectionGestureListener(directionListener));
}
private static class DirectionGestureListener extends GestureAdapter{
DirectionListener directionListener;
public DirectionGestureListener(DirectionListener directionListener){
this.directionListener = directionListener;
}
@Override
public boolean fling(float velocityX, float velocityY, int button) {
if(Math.abs(velocityX)>Math.abs(velocityY)){
if(velocityX>0){
directionListener.onRight();
}else{
directionListener.onLeft();
}
}else{
if(velocityY>0){
directionListener.onDown();
}else{
directionListener.onUp();
}
}
return super.fling(velocityX, velocityY, button);
}
}
}