图形 - 重叠错误还是什么?
我这里有相当大的代码...但幸运的是根本不需要提及。归根结底是……失败了?所以,最后应该绘制两个三角形(使用 AS3 Graphics)。它对一个来说工作得很好,但是当我把第二个放在那里时,它看起来很奇怪。我跟踪调试了它,我认为错误在图形中 - 这是我绘制的实际点的输出:
DRAW
- POINT ( 50 , -50 )
- POINT ( -50 , 50 )
- POINT ( 50 , 50 )
DRAW
- POINT ( -50 , -50 )
- POINT ( 50 , -50 )
- POINT ( -50 , 50 )
(x,y),两个三角形。这将产生一种颜色的正方形(这些三角形是一种颜色),或者如果我要改变颜色,可能会产生一个分成两半的正方形。
会……不会。
,我得到这个:
相反,当我切换三角形绘制的顺序时 或者(这很奇怪) :
...
知道发生了什么吗? 我在另一个论坛上读到,应该在绘制每个形状之前和之后调用函数 beginFill 和 endFill - 显然这就是我在查看之前所做的 - 否则颜色不会有所不同。那么 - 有什么想法吗?
编辑:
图形调用如下所示:
for (var vi:int = 0; vi < triangles.length; vi++){
gfx.beginFill(0xFF0000, 0.5 + (0.5 * vi));
trace("DRAW");
trace("- POINT ( " + triangles[vi].points[0].x + " , " + triangles[vi].points[0].y + " )");
trace("- POINT ( " + triangles[vi].points[1].x + " , " + triangles[vi].points[1].y + " )");
trace("- POINT ( " + triangles[vi].points[2].x + " , " + triangles[vi].points[2].y + " )");
gfx.lineTo(triangles[vi].points[0].x, triangles[vi].points[0].y);
gfx.lineTo(triangles[vi].points[1].x, triangles[vi].points[1].y);
gfx.lineTo(triangles[vi].points[2].x, triangles[vi].points[2].y);
gfx.lineTo(triangles[vi].points[0].x, triangles[vi].points[0].y);
gfx.endFill();
}
I have quite a big code here... But fortunately it is not needed to be mentioned at all. It comes down to something which... fails? So, in the end this is supposed to draw two triangles (using AS3 Graphics). It works fine with one, but when I put a second there, it looks weird. I trace debugged it, and I think the bug is in the Graphics - this is my output for the actual points drawn:
DRAW
- POINT ( 50 , -50 )
- POINT ( -50 , 50 )
- POINT ( 50 , 50 )
DRAW
- POINT ( -50 , -50 )
- POINT ( 50 , -50 )
- POINT ( -50 , 50 )
(x, y), two triangles. This would result in a square of one color (these triangles are one colored), or possibly a square split in half if I were to change the colors.
Would... It does not.
Instead, I get THIS:
OR (which is weird), when I switch the order in which the triangles are drawn:
...
Any idea what is going on?
I have read on another forum that functions beginFill and endFill are supposed to be called before and after drawing every shape - obviously that's what I did even before looking - the color won't be different elsehow. So - any idea?
EDIT:
The graphics calls look like this:
for (var vi:int = 0; vi < triangles.length; vi++){
gfx.beginFill(0xFF0000, 0.5 + (0.5 * vi));
trace("DRAW");
trace("- POINT ( " + triangles[vi].points[0].x + " , " + triangles[vi].points[0].y + " )");
trace("- POINT ( " + triangles[vi].points[1].x + " , " + triangles[vi].points[1].y + " )");
trace("- POINT ( " + triangles[vi].points[2].x + " , " + triangles[vi].points[2].y + " )");
gfx.lineTo(triangles[vi].points[0].x, triangles[vi].points[0].y);
gfx.lineTo(triangles[vi].points[1].x, triangles[vi].points[1].y);
gfx.lineTo(triangles[vi].points[2].x, triangles[vi].points[2].y);
gfx.lineTo(triangles[vi].points[0].x, triangles[vi].points[0].y);
gfx.endFill();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一个
gfx.lineTo
应该是gfx.moveTo
。The first
gfx.lineTo
should be agfx.moveTo
.