draw_set_alpha似乎不使用draw_retectangle

发布于 2025-01-22 14:09:23 字数 758 浏览 0 评论 0原文

我的目标: 我正在尝试通过当前视图绘制一个透明的黑色矩形。

问题: 无论我设置了什么alpha,矩形都是用完全不透明度绘制的。

我尝试过的东西

  1. 我尝试了更改矩形的颜色确保我在代码的正确部分中查找。 (不透明的矩形的颜色发生了变化,使我相信这是代码中的正确位置。)
  2. 我尝试删除draw_rectangle_color()的呼叫代码。 (矩形不再被绘制,使我相信这是代码中的正确位置。)
  3. 我尝试在绘制矩形之前立即进行 draw_set_set_alpha(0),但仍以完全不透明度绘制。
  4. 我也尝试在绘制矩形之前直接执行 image_alpha = 0 ,但仍以完全不透明度绘制。 (没想到这会起作用,但值得一试)
var rectColor = c_black;
var rectAlpha = 0.2;

draw_set_alpha(rectAlpha);
draw_rectangle_color(viewX, viewY, viewX+viewW, viewY+viewH, 
                     rectColor,rectColor,rectColor,rectColor,
                     false);
draw_set_alpha(1);

MY GOAL:
I'm trying to draw a transparent black rectangle over the current view.

THE PROBLEM:
No matter what alpha I set, the rectangle is drawn with full opacity.

THINGS THAT I'VE TRIED:

  1. I tried changing the color of the rectangle to make sure that I'm looking in the correct part of the code. (The opaque rectangle's color changed, leading me to believe that this is the correct spot in the code.)
  2. I tried removing this call to draw_rectangle_color() to make sure that I'm looking in the correct part of the code. (The rectangle stopped being drawn, leading me to believe that this is the correct spot in the code.)
  3. I tried doing draw_set_alpha(0) immediately before drawing the rectangle, but it was still drawn with full opacity.
  4. I tried also doing image_alpha = 0 immediately before drawing the rectangle, but it was still drawn with full opacity. (didn't expect this to work, but it was worth a shot)
var rectColor = c_black;
var rectAlpha = 0.2;

draw_set_alpha(rectAlpha);
draw_rectangle_color(viewX, viewY, viewX+viewW, viewY+viewH, 
                     rectColor,rectColor,rectColor,rectColor,
                     false);
draw_set_alpha(1);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

不气馁 2025-01-29 14:09:23

固定
我正在使用一个覆盖alpha为1的着色器。draw_set_alpha

正常使用。

()与draw_rectangle_color() :)

FIXED
I was using a shader that was overwriting the alpha to be 1.

draw_set_alpha() works properly with draw_rectangle_color()

:)

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