1

I am developing game, in that game there will be grid of circles and player will connect those circles by connecting two circles with line vertically or horizontally, diagonal selection will not be allowed. What I have done so far is that on canvas I have drawn circles on board and I have displayed line when user swipes on screen. I want to limit line's length according to internal distance of two circles and I also want to display horizontal and vertical line and it should not allow line other then these two. lineDraw() method should take starting and ending parameters from drawCircles()'s x, y coordinates instead of taking input run-time from user. This is screen shot.

Example

    public boolean onTouch(View v, MotionEvent e) {
        int action=e.getAction();
        switch(action)
        {
        case MotionEvent.ACTION_DOWN:
            downx=e.getX();
            downy=e.getY();
            Log.d("Umar", String.valueOf(downx));
            Log.d("Farooq", String.valueOf(downy));
            break;
        case MotionEvent.ACTION_MOVE:
            break;
        case MotionEvent.ACTION_UP:
            upx=e.getX();
            upy=e.getY();
            canvas.drawLine(downx, downy, upx, upy, paint);
            imageView.invalidate();
            break;
        case MotionEvent.ACTION_CANCEL:
            break;
            default:
                break;
        }
        return true;
    }

}
Umar Farooq
  • 127
  • 1
  • 2
  • 19

0 Answers0