Reputation: 21
In my game, if the player goes through a door, I would like to have text appear for one second and then fade out.
I'm using GameMaker:Studio 1.4
Upvotes: 2
Views: 1855
Reputation: 135
Create an object, for example obj_text
, with the following events:
Create event:
alpha = 1;
fade_out = false;
alarm[0] = 60; // Time in frames
Alarm 0 event:
fade_out = true;
Step event:
if (fade_out) {
alpha -= 0.05;
}
if (alpha <= 0) {
instance_destroy();
}
Draw event:
draw_set_alpha(alpha);
draw_text(x, y, "You went through a door");
draw_set_alpha(1);
When the player goes through a door, simply use instance_create(x, y, obj_text)
to display the text.
Upvotes: 2
Reputation: 293
Create event:
count = 0
alpha = 1
delay = 1 // in seconds
Step event:
if (count == room_speed * delay) {
alpha -= 0.05
draw_set_alpha(alpha)
if (image_alpha <= 0) {
instance_destroy();
}
}
else {
count += 1
}
draw_text(x, y, "You went through a door")
draw_set_alpha(1);
When the player goes through the door you simply use
instance_create( x, y, obj_text)
to display the text.
You can change the value of delay to define how long the text should be shown until it starts to fade out.
Upvotes: 0