开发者

How to draw circle when Tab event is fired

开发者 https://www.devze.com 2023-04-10 14:32 出处:网络
I am learning android Live wallpaper development. I found an awesome template in the AndEngine Forums

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

精彩评论

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

关注公众号