我目前正在为Android(API级别7)编写非常简单的游戏来发现和学习android SDK.此游戏涉及在屏幕上绘制形状,触摸时会改变颜色.
某些形状可能嵌入一个或多个孔.我的问题是:如果我触摸形状,整个事物的颜色变化,甚至是孔洞.这是我使用的伪代码,shape是我想绘制的多边形,边界是它的外边界,是一个洞的数组.洞和边界保持他们的点数组.
Path MyPath = Path();
Path.moveTo(boundary.points[0].x, boundary.point[0].x);
for (point in boundary) {
MyPath.lineTo(point.x, point.y);
}
Path.close();
for (hole in shape.holes) {
MyPath.moveTo(hole.points[0].x,hole.points[0].y);
for (point in hole) {
MyPath.lineTo(point.x, point.y);
}
MyPath.close();
}
// setting Paint here...
canvas.drawPath(MyPath, MyPaint);
Run Code Online (Sandbox Code Playgroud)
他们在Android中关于路径的东西是我缺少的,还是你有其他方法可以做到这一点?
您确定使用的是正确的路径填充规则吗?如果您使用例如WINDING填充规则,则孔必须在相对于外边界的相反方向上(例如,逆时针方向的边框和顺时针方向的孔)
| 归档时间: |
|
| 查看次数: |
4880 次 |
| 最近记录: |