图形 - 重叠错误还是什么?

发布于 2024-09-19 17:46:34 字数 1462 浏览 6 评论 0原文

我这里有相当大的代码...但幸运的是根本不需要提及。归根结底是……失败了?所以,最后应该绘制两个三角形(使用 AS3 Graphics)。它对一个来说工作得很好,但是当我把第二个放在那里时,它看起来很奇怪。我跟踪调试了它,我认为错误在图形中 - 这是我绘制的实际点的输出:

DRAW
- POINT ( 50 , -50 )
- POINT ( -50 , 50 )
- POINT ( 50 , 50 )
DRAW
- POINT ( -50 , -50 )
- POINT ( 50 , -50 )
- POINT ( -50 , 50 )

(x,y),两个三角形。这将产生一种颜色的正方形(这些三角形是一种颜色),或者如果我要改变颜色,可能会产生一个分成两半的正方形。

会……不会。

,我得到这个:

alt text

相反,当我切换三角形绘制的顺序时 或者(这很奇怪) : alt text

...

知道发生了什么吗? 我在另一个论坛上读到,应该在绘制每个形状之前和之后调用函数 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:

alt text

OR (which is weird), when I switch the order in which the triangles are drawn:
alt text

...

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-09-26 17:46:34

第一个 gfx.lineTo 应该是 gfx.moveTo

The first gfx.lineTo should be a gfx.moveTo.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文