我正在创建一个测试游戏,其中一个圆圈在被触摸时将移动到点数组列表中的选定位置。但是,单击时似乎无法移动到点的下一个位置。你能帮我找出问题出在哪里以及我可以使用什么解决方案吗?
public class EyeTestActivity extends AppCompatActivity {
private GestureDetectorCompat mDetector;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(new TestView(this));
// get the gesture detector
mDetector = new GestureDetectorCompat(EyeTestActivity.this, new SwipeGestureDetector());
}
public boolean onTouchEvent(MotionEvent motionEvent) {
this.mDetector.onTouchEvent(motionEvent);
return super.onTouchEvent(motionEvent);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
super.dispatchTouchEvent(ev);
return mDetector.onTouchEvent(ev);
}
public class TestView extends View {
public ArrayList<Point> pointlist;
Paint paint;
public TestView(Context context) {
super(context);
init();
setFocusable(true);
setFocusableInTouchMode(true);
createPointList();
}
public void init() {
paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStrokeWidth(5);
paint.setStyle(Paint.Style.STROKE);
}
我希望在打印时绘制下一个圆圈。
汪汪一只猫
相关分类