public boolean onTouchEvent(MotionEvent event){
int action = event.getAction();
switch(action){
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
final float a = event.getX();
final float b = event.getY();
if(Math.sqrt(Math.pow(a - 160, 2) + Math.pow(b - 100, 2)) <= RADIUS){
myPaint1.setColor(Color.RED);
}
else if(Math.sqrt(Math.pow(a - 160, 2) + Math.pow(b - 140, 2)) <= RADIUS){
myPaint2.setColor(Color.RED);
}
else if(Math.sqrt(Math.pow(a - 160, 2) + Math.pow(b - 160, 2)) <= RADIUS){
myPaint3.setColor(Color.RED);
여기에 메소드를 추가해서 마지막원 클릭시 Paint[] paint1이 사라지고Paint[] paint2가 생성되도록 하고 싶어요
}
if(Math.sqrt(Math.pow(a - 100, 2) + Math.pow(b - 140, 2)) <= RADIUS){
myPaint1.setColor(Color.RED);
}
else if(Math.sqrt(Math.pow(a - 120, 2) + Math.pow(b - 160, 2)) <= RADIUS){
myPaint2.setColor(Color.RED);
}
else if(Math.sqrt(Math.pow(a - 140, 2) + Math.pow(b - 180, 2)) <= RADIUS){
myPaint3.setColor(Color.RED);
}
return true;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
break;
}
return(true);
}
@Override
public void onDraw(Canvas canvas){
int width = canvas.getWidth();
int height = canvas.getHeight();
canvas.drawRect(0, 0, width, height, backgroundPaint);
int[] start1 ={160,160,160};
int[] end1 = {100,120,140};
Paint[] paint1 = {backgroundPaint, myPaint1, myPaint2, myPaint3};
for (int i=0; i<start1.length; i++) {
canvas.drawCircle(start1[i],end1[i],RADIUS,paint1[i]);
int[] start2 = {100,120,140};
int[] end2 = {140,160,180};
Paint[] paint2 = {backgroundPaint, myPaint7, myPaint8, myPaint9};
for (int a=0; a<start2.length; a++) {
canvas.drawCircle(start2[i],end2[i],RADIUS,paint2[i]);
}
invalidate();
}
}
}
위에 코드가 더 있긴했는데 별로 필요가 없을거 같아 생략했습니다.
코드 중간에 질문 적어놨는데 어떤 메소드를 쓰면 좋을지 잘 모르겠어요 ㅜㅜ 아직 자바초보라서요 ....ㅜ
많은 도움 주세욤~




온드로우 멈춰버리면 일단 출력은 중단되는데
플레그줘서 온드로우 내에서 사용될 페인트함수들을 결정해서 출력하게끔 하면 될련지;;
일단 플레그 줘서 온드로우 내에서 페인트 함수들을 선택적으로 출력하게 만들고 디버그모드에서
중단점걸고 단계실행 해보세용