I'm using GameMaker 2.
Trying to get a piece of code to work that when an alarm hits 12 seconds, it changes a global variable within the object which then triggers the object to carry out it's normal process - fading the screen out to black. However it isn't working and I can't figure out what isn't working.
This is the code I have at the moment;
Create:
variable_timer = 100;
global.fadeoutsimilarities = 0;
alarm[0] = room_speed * 12;
Step:
variable_timer-=1;
Alarm 0:
global.fadeoutsimilarities = global.fadeoutsimilarities + 1;
Draw:
if (global.fadeoutsimilarities)
{
draw_set_color(c_black);
draw_set_alpha(variable_timer/30);
}
else {}
Any ideas on what's preventing it from fading out to black?
The variebla global.fadeoutsimilarities = 0;
it is a numeric variable and when placing global.fadeoutsimilarities = global.fadeoutsimilarities + 1;
you are telling him to add up to 1, then I will be 1 then 2, 3, 4, ... and so, and in event draw you place the conditional if (global.fadeoutsimilarities)
which means if global.fadeoutsimilarities = 1
it will be black, but this will only happen during a frame in a blink, the solution is to change the values of global.fadeoutsimilarities by true and false,
it would look like this:
Create:
variable_timer = 10;
global.fadeoutsimilarities = false;
alarm [0] = room_speed * 12;
Step:
//without code
Alarm 0:
global.fadeoutsimilarities = true;
variable_timer -=1;
Draw:
if (global.fadeoutsimilarities)
{
draw_set_color (c_black);
draw_set_alpha (variable_timer / 10);
}
if you have doubts write me www.facebook.com/BusyClown
If I help you with something, give me a +1