资 源 简 介
Android 绘制吃豆子小人,同时与之搭配的还有图片自动变换显示的功能。
Paint paint = new Paint();//创建画笔对象
canvas.drawColor(Color.BLACK);//绘制背景
canvas.drawBitmap(bmpMan, centerX-radius, centerY-radius, null);//绘制吃豆小人
paint.setColor(Color.BLACK); //设置画笔颜色
paint.setAntiAlias(true);
RectF oval = new RectF(centerX-radius-1,centerY-radius-2,centerX-radius-1+2*radius+2,centerY-radius-2+2*radius+4);
canvas.drawArc(oval, 360-angle+90*direction, 2*angle, true, paint); //绘制扇形实现张嘴闭嘴
if(System.currentTimeMillis()-timeStamp > 5000){//如果时间间隔超过5秒
timeStamp = System.currentTimeMillis(); //重新记录时间
currPhoto = (currPhoto+1)%bmpPhotos.length; //更换照片
}
canvas.drawBitmap(bmpPhotos[currPhoto], 80, 40, null);//绘制照片
super.onDraw(canvas);