// 새로운 볼 생성 public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { Ball NewBall = Ball.Create((int) event.getX(), (int) event.getY(), RAD); arBall.add(NewBall); invalidate(); return true; } return false; }
private void handleLongPress(MotionEvent event) { QuranAyah result = getAyahFromCoordinates(event.getX(), event.getY()); if (result != null) { mImageView.highlightAyah(result.getSura(), result.getAyah()); mImageView.invalidate(); mImageView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); // TODO Temporary UI until new UI is implemented new ShowAyahMenuTask().execute(result.getSura(), result.getAyah(), mPageNumber); } }
public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { int sel; sel = FindShapeIdx((int) event.getX(), (int) event.getY()); // 빈 바닥을 찍었으면 무시한다. if (sel == -1) { return true; } // 마지막 추가된 도형을 제대로 찍었으면 다음 단계로 진행. // 빈 화면 잠시 보여준 후 새 도형 추가 if (sel == arShape.size() - 1) { status = BLANK; invalidate(); mHandler.sendEmptyMessageDelayed(0, DELAY); // 엉뚱한 도형을 찍었으면 질문 후 게임 종료 또는 재시작 } else { new AlertDialog.Builder(getContext()) .setMessage("재미있지! 또 할래?") .setTitle("게임 끝") .setPositiveButton( "함더", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { arShape.clear(); status = BLANK; invalidate(); mHandler.sendEmptyMessageDelayed(0, DELAY); } }) .setNegativeButton( "안해", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mParent.finish(); } }) .show(); } return true; } return false; }