我是编程新手,主要是自学和使用书籍,并从其他人在这个论坛上提出的问题中得到很多帮助。我目前正在为假人开发 android 游戏,遇到了几个问题,其中大部分我已经能够自己解决,但是我无法解决这个编译器错误。它无法识别代码中的 canvas.drawCircle。我不知道为什么。非常感谢任何帮助或想法。提前谢谢汤姆
public class CrazyEightsView extends View {
private Paint redPaint;
private int circleX;
private int circleY;
private float radius;
public CrazyEightsView(Context context) {
super(context) ;
redPaint = new Paint();
redPaint.setAntiAlias(true);
redPaint.setColor(Color.rgb(99, 00, 00));
circleX=100;
circleY=100;
radius=30;
}
@Override
public void onDraw (Canvas canvas) {
}
public boolean onTouchEvent (MotionEvent event) {
int eventaction = event.getAction();
int X =(int)event.getX();
int Y =(int)event.getY();
switch (eventaction){
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
break;
case MotionEvent.ACTION_UP:
circleX = X;
circleY = Y;
break;
invalidate();
return true;
}
canvas.drawCircle (circleX, circleY, radius, redPaint);
}
}