Login | Register

Room Fade

June 28, 2006, 18:19 by David
[loading]
-->
To make a room fade in

Create a new sprite, name it to "fade" and fill it with black. Make sure it isn't transparent!

Add a new object, name it to "fade_in" and apply the sprite "fade" to it. Put this in the create event:
Speed = 0.05;
x = 0;
y = 0;
image_xscale = room_width;
image_yscale = room_height;
image_alpha = 1;


And this in the step event:
image_alpha -= Speed;
if image_alpha ==0 || image_alpha <=0
instance_destroy();


Put this in the rooms you want to fade in..

To make a room fade out

Add a new object, name it to "fade_out" and apply the sprite "fade". Put this in the create event:
Speed = 0.05;
goto_room = 'no';
x = 0;
y = 0;
image_xscale = room_width;
image_yscale = room_height;
image_alpha = 0;


And this in the step event:
if string(goto_room) != 'no' {
image_alpha+= Speed;

if image_alpha==1 || image_alpha >= 1 {
if string(goto_room) == 'next'
room_goto_next();
else if string(goto_room) == 'restart'
room_restart();
else if string(goto_room) == 'exit'
game_end();
else
room_goto(goto_room);
}
}


Put this in the rooms you want to able to fade out and call one of the following lines to fade out:
fade_out.goto_room = room_name; //Fade out to another room
fade_out.goto_room = "next"; //Fade out to the next room
fade_out.goto_room = "restart"; //Restart the current room
fade_out.goto_room = "exit"; //End the game

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games