Discord
Login
Community
DARK THEME

setAlpha and fillRect

It seems that setAlpha is not functioning, at least when using fillRect.

In my current project (js), I want to draw a semi transparent layer on top of my screen, so I have the following at the end of my draw function.

  screen.setAlpha=.4;
  screen.fillRect(0,0,screen.width,screen.height,"#222");
  screen.setAlpha=1;

However, the rectangle draw in opaque. Is this a bug?

".4" is a syntax error.

screen.setAlpha=0.4;

I'm afraid this is not correct. As far as javascript is concerned, 0.4 and .4 are the same. In any case, even changing my code to:

screen.setAlpha=0.4;
screen.fillRect(0,0,screen.width,screen.height,"#222");
screen.setAlpha=1;

does not make a difference. The output is the same. It's like the screen.setAlpha commands are ignored.

screen.setAlpha() is a function, so try screen.setAlpha(0.4)

And you'd think the "set" part should have made it clear... 😳

Thanks.

Oh. I don't know about JavaScript.I am used to Python, Lua. And it will be clearer next time I answer, sorry.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community