Bentley
Member
Hello. Just a heads up, I'm a beginner.
I made a room transition object that draws a rectangle over the screen. It fades in in room 1, and then fades out in room 2. Here's the code. (I'm sorry for the lack of indentation. After I posted, the indentation was removed).
draw_set_alpha( alpha );
draw_rectangle( 0, 0, room_width, room_height, false );
if( fade == "in" )
{
if( alpha < 1 ) alpha += 0.01;
else
{
alpha = 1;
room_goto_next();
fade = "out";
}
}
if( fade == "out" )
{
if( alpha > 0 ) alpha -= 0.01;
else instance_destroy();
}
draw_set_alpha( 1 );
If I understand the Draw event correctly (which I'm sure I don't), it runs every step, and it also runs every line of code every step. So going off that bad logic, why doesn't the last line, which defaults opacity to 1, not turn the screen black at the end of that step? (And at the start of the next step, draw_set_alpha( alpha ) would set opacity back to the value of the variable alpha).
Thank you for reading. By the way, if you see anything unrelated that I can improve on, please let me know.
I made a room transition object that draws a rectangle over the screen. It fades in in room 1, and then fades out in room 2. Here's the code. (I'm sorry for the lack of indentation. After I posted, the indentation was removed).
draw_set_alpha( alpha );
draw_rectangle( 0, 0, room_width, room_height, false );
if( fade == "in" )
{
if( alpha < 1 ) alpha += 0.01;
else
{
alpha = 1;
room_goto_next();
fade = "out";
}
}
if( fade == "out" )
{
if( alpha > 0 ) alpha -= 0.01;
else instance_destroy();
}
draw_set_alpha( 1 );
If I understand the Draw event correctly (which I'm sure I don't), it runs every step, and it also runs every line of code every step. So going off that bad logic, why doesn't the last line, which defaults opacity to 1, not turn the screen black at the end of that step? (And at the start of the next step, draw_set_alpha( alpha ) would set opacity back to the value of the variable alpha).
Thank you for reading. By the way, if you see anything unrelated that I can improve on, please let me know.
Last edited: