我想使用自定义png而不是canvas.drawcircle函数.怎么能做到



int currentX=maze.getCurrentX(),currentY=maze.geCurrentY();//划球

    canvas.drawCircle((currentX * totalCellWidth)+(cellWidth/2),   //x of center
              (currentY * totalCellHeight)+(cellWidth/2),  //y of center
              (cellWidth*0.45f),                           //radius
              ball);
    //draw the finishing point indicator
    canvas.drawText("F",
                    (mazeFinishX * totalCellWidth)+(cellWidth*0.25f),
                    (mazeFinishY * totalCellHeight)+(cellHeight*0.75f),
                    ball);
}

您必须将png添加到drawable文件夹中。则可以使用CCD_ 3创建CCD_。位图可以使用canvas.drawBitmap(Bitmap bmp, Rect source, Rect dest, Paint p)在画布上绘制。bmp是要绘制的位图,显然,source是要绘制位图的一部分(在您的情况下是整个位图),dest是画布上绘制位图的位置,p是油漆,您不需要,所以只需使用null

最新更新