Sprite.alpha not working in this project?

This is a student project… can’t figure out why camo.alpha is not working in the draw loop.

We’re happy to help. Could you include the share link for the project, what you expect to happen, and what is happening instead? That will help us know how to help.

What I expect to happen is that camo sprite (the background) alpha will be set to 0.1 when the program runs and we will see a mostly transparent background. I added a watcher and indeed it is being set to 0.1, but when the image is rendered, it rapidly fades in as if the aplha is being increased to 1 (almost as if the command is camo.apha+=0.1; When I change the command to something like camo.alpha = 0.9, the fade in doesn’t happen, it just appears opaque from the beginning.

@134852e,

since you put the code inside the draw loop, it is redrawn every pass of the loop. Once you have run the loop 10 times, it will have multiplied the .1 and made it fully opaque. One way to prevent this would be to add a white background to the beginning of the draw loop. That way, it would be reset every time the loop passes and then your .1 alpha value will stick. (by the way, .1 is super faint).

Hope this helps!

Mike

Think of it like a stack of semi-transparent lenses. Each time the draw loop is executed it adds another layer. Eventually, it is no longer transparent at all. If you clear the camo before calling it in the draw loop, it will clear out the old one each time leaving you with just a semi-transparent background. Here’s how I did it. I just saw @mwood 's suggestion. I like that too!

1 Like