• 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!

GameMaker Make a object 'blink'

B

Bokkie2988

Guest
Hey,

As the title says. How would I make a object blink with image_alpha?

-Bokkie
 

FrostyCat

Redemption Seeker
Do people not learn how to use alarms and variables as part of their GML training anymore?

Create:
Code:
blink = true;
alarm[0] = 0.5*room_speed;
Alarm 0:
Code:
blink = !blink;
image_alpha = blink ? 1 : 0.25;
alarm[0] = 0.5*room_speed;
 

Slyddar

Member
You could also do it without an alarm like this:

CREATE
Code:
blink_time = 0;
blink_length = 30;
blink_alpha = 0.25;
STEP:
Code:
//set image_alpha
if blink_time++ > blink_length image_alpha = blink_alpha else image_alpha = 1;

//reset time
if blink_time > blink_length * 2 blink_time = 0;
 
Last edited:
B

Bokkie2988

Guest
You could also do it without an alarm like this:

CREATE
Code:
blink_time = 0;
blink_length = 30;
blink_alpha = 0.25;
STEP:
Code:
//set image_alpha
if blink_time++ > blink_length image_alpha = blink_alpha else image_alpha = 1;

//reset time
if blink_time > blink_length * 2 blink_time = 0;
Is this a smooth transition btw? Because I need that
 

FrostyCat

Redemption Seeker
Is this a smooth transition btw? Because I need that
If you wanted a smooth transition, you should have said that from the start, not after you get a response.

Create:
Code:
blink_theta = 0;
blink_theta_rate = 4;
Step:
Code:
blink_theta = (blink_theta+blink_theta_rate) mod 360;
image_alpha = 0.5*(dcos(blink_theta)+1);
 

Yal

šŸ§ *penguin noises*
GMC Elder
Even simpler: in Step event, put
image_alpha = 0.5 + lengthdir_x(0.5,current_time*0.25)
 
Top