开发者

How to draw circle when Tab event is fired

I am learning android Live wallpaper development. I found an awesome template in the AndEngine Forums In this template I found an overridable method OnTab which provides 2 parameters i.e x coordintate & y coordinate .

   protected void onTap(final int pX, final int pY)
{
    SurfaceHolder holder= //Get current surface holder object
    Paint paint = new Paint();
    Canvas canvas= holder.lockCanvas();
    paint.setColor(Color.WHITE);
    canvas.drawCircle(20, 50, 25, paint);
}

I want to draw a circle when user tabs or touches the screen but i am finding it difficult to get the sufaceholder object which will 开发者_如何学运维let me draw a circle on the canvas Or can i achieve this some other way?


You need to do the drawing within the onDraw() method. When a touch is occurring you should save the X and Y location and then in the onDraw() method draw the circle.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜