• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Help Flickering Sprite

W

Willowwisp001

Guest
I'm trying to get a white square to randomly change transparency between 5 and 0.5.
I want the object sprite to randomly flicker

like flickering lights :)

something like:

between 5 and 0.5
randomly change
image_alpha += 1;
 

rIKmAN

Member
I'm trying to get a white square to randomly change transparency between 5 and 0.5.
I want the object sprite to randomly flicker

like flickering lights :)

something like:

between 5 and 0.5
randomly change
image_alpha += 1;
If you check the manual and read the description for image_alpha you will see it only takes a value between 0.0 - 1.0.

https://docs.yoyogames.com/source/dadiospice/002_reference/objects and instances/instances/instance properties/image_alpha.html

You can either set the image_alpha to a random value between 0.5 - 1.0 before drawing the sprite using draw_self(), or use draw_sprite_ext() and use a random number for the alpha parameter.

Notable manual entries:
image_alpha
draw_sprite_ext()
randomize()
random_range()
Code:
image_alpha = random_range(0.5, 1.0);
draw_self();
Code:
draw_sprite_ext(sprite_index, image_index, x, y, 1, 1, 0, c_white, random_range(0.5, 1.0));
The manual is your friend.
 
Last edited:

Bingdom

Googledom
Before you start to make another post, I suggest you read this.

What have you tried to solve the problem? Have you tried to do a bit of research?
 
Top