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

Moving rooms with a Fade object

E

Ealonex

Guest
When trying to move between rooms with fade, the next room loads before Fade is played.
scr_startmenu:
switch (mpos)
{
case 0:
{
audio_play_sound(snd_menu_select,11,false)
instance_create(view_wview, view_hview,obj_fade);
room_goto(rm_forest)

break;

}

obj_fade's create:
/// fade.
a = 0;
fade = 1;


obj_fade's draw:

/// draw leh ractangol
a = clamp(a + (fade * 0.03),0,1)

if (a == 1)
{
fade = -1;
}
if (a == 0) and (fade == -1)
{
instance_destroy();
}

draw_set_color(c_black);
draw_set_alpha(a)
draw_rectangle(
view_xview[0],
view_yview[0],
view_xview[0] + view_wview[0],
view_yview[0] + view_hview[0],
0,

)
draw_set_alpha(1);

Any way for me to make this work without making any major changes? And If I have to make major changes, is there any way for me to make transitions more flexible like fixed movement in between rooms (such as going in a house actually showing the characters moving in the house before you can actually move.)

Thanks!
 
P

PlayLight

Guest
You're switching to rm_forest immediately after creating your fade object, which isn't letting obj_fade perform it's task.
You'll want to call for rm_forest after the fade is completed.

or if you're fading in, then call for obj_fade on room create.

Edit:
Just a heads up bud, for future posts, this kind of topic should go under 'Programming'.
 
Last edited by a moderator:
E

Ealonex

Guest
Ahhh sorry, wrong section.

So how do I make sure that the call for rm_forest comes after and only after fade? I tried to do something like
if obj_fade.a = 0
{
room_goto(rm_forest)

}

but that didn't work either. I'm still a little unclear on how to work with switches and ifs inside of ifs
 
P

PlayLight

Guest
There's many ways to go about it. As a simple example, you could write obj_fade to handle both fade in and fade out animations.

-------------------------------------------------------------------------------------------------
obj_fade
[ CREATE EVENT ]
Code:
image_alpha     = 0;
fade_speed      = 0.05;
target_room     = noone;
[ ALARM[0] ]
Code:
/// FADE OUT

if ( image_alpha < 1 )
    {
    image_alpha  += fade_speed;
    alarm[0]      = 1;
    }
else
    {
    room_goto( target_room );
    }
[ ALARM[1] ]
Code:
/// FADE IN

if ( image_alpha > 0 )
    {
    image_alpha  -= fade_speed;
    alarm[1]      = 1;
    }
else
    {
    instance_destroy();
    }
[DRAW EVENT] or [DRAW GUI EVENT]
Code:
/// DRAW FADE

draw_set_alpha( image_alpha );
draw_set_color( c_black );
draw_rectangle( view_xview[0], view_yview[0], view_xview[0] +view_wview[0], view_yview[0] +view_hview[0], false );
draw_set_alpha(1);
-------------------------------------------------------------------------------------------------
Then use the following scripts when you need to either fade in or fade out.

scr_room_fade_out( target_room );
Code:
with ( instance_create( 0, 0, obj_fade ) )
    {
    image_alpha = 0;
    target_room = argument0;
    alarm[0]    = 1;
    }

scr_room_fade_in();
Code:
with ( instance_create( 0, 0, obj_fade ) )
    {
    alarm[1]    = 1;
    }

scr_room_fade_in() can be used in the room create event.
 
Last edited by a moderator:
J

jackhigh24

Guest
you can put the room goto in the destroy event of object fade or just right after you say instance destroy in object fade
 
E

Ealonex

Guest
So from the looks of it, *scr_room_fade_out( target_room );*
Is supposed to be used to transfer from one room to the next, correct? And I'm supposed to put scr_room_fade_in() in all of my room's creation code?
My game's title screen does fade out, but does not fade back in. I don't think I'm putting the script in the right place.
 
P

PlayLight

Guest
So from the looks of it, *scr_room_fade_out( target_room );*
Is supposed to be used to transfer from one room to the next, correct? And I'm supposed to put scr_room_fade_in() in all of my room's creation code?
My game's title screen does fade out, but does not fade back in. I don't think I'm putting the script in the right place.
Here's a little project to show you how it works.
FadeMe

edit:
You can set the speed of the fade, in obj_fade's create event using fade_speed
 
Last edited by a moderator:
E

Ealonex

Guest
Here's a little project to show you how it works.
FadeMe

edit:
You can set the speed of the fade, in obj_fade's create event using fade_speed
Alright so I believe my problem comes from the fact that I'm actually working with a script to make the menu work. Here's what I placed for all of the objs and scrs that matter:
start menu script
Code:
/// scr_startmenu
switch (mpos)
{
    case 0: 
    {
        audio_play_sound(snd_menu_select,11,false)
       scr_room_fade_out(rm_forest);
       
       
        break;
   
    }
Both the startmenu and the rm_forest both have
Code:
 scr_room_fade_in();
in them.

My start menu fades to black and my rm_forest does not appear.
 
P

PlayLight

Guest
Alright so I believe my problem comes from the fact that I'm actually working with a script to make the menu work. Here's what I placed for all of the objs and scrs that matter:
start menu script
Code:
/// scr_startmenu
switch (mpos)
{
    case 0:
    {
        audio_play_sound(snd_menu_select,11,false)
       scr_room_fade_out(rm_forest);
    
    
        break;

    }
Both the startmenu and the rm_forest both have
Code:
 scr_room_fade_in();
in them.

My start menu fades to black and my rm_forest does not appear.
Is rm_forest actually being created?
(add: show_debug_message(">> rm_forest <<"); to the rm_forest create code and see if it appears in the logcat)
if it does you may be using persistence on the previouse room. In that case you would simply adjust obj_fade alarm[0] to:
Code:
/// FADE OUT

if ( image_alpha < 1 )
    {
    image_alpha  += fade_speed;
    alarm[0]      = 1;
    }
else
    {
    instance_destroy(); // destroy itself
    room_goto( target_room );
    }
to make it destroy itself.
 
Last edited by a moderator:
E

Ealonex

Guest
Is rm_forest actually being loaded?
(add: show_debug_message(">> rm_forest <<"); to the rm_forest create code and see if it appears in the logcat)
if it does you may be using persistence on the previouse room. In that case you would simply adjust obj_fade alarm[0] to:
Code:
/// FADE OUT

if ( image_alpha < 1 )
    {
    image_alpha  += fade_speed;
    alarm[0]      = 1;
    }
else
    {
    instance_destroy(); // destroy itself
    room_goto( target_room );
    }
to make it destroy itself.
YES. THANK YOU SO MUCH.
I'm soooo greatful for this. Thank you so much!
 
P

PlayLight

Guest
Any time!
I would ask for a high-five, but unfortunately there's no high-five Emoticons..
:(
 
E

Ealonex

Guest
Any time!
I would ask for a high-five, but unfortunately there's no high-five Emoticons..
:(
Ahhh I'm stuck again :(

I'm now at the point where I want to be able to transit from one room to the next but they should appear naturally. Example being leaving one room on it's left side and entering the next on it's right. I'm trrying to do this via a warp system but it's flying all over my head! I've no idea where to start with this at all. With the fade script? With the fade object? With the warp object? I don't even know.
 
P

PlayLight

Guest
Ahhh I'm stuck again :(

I'm now at the point where I want to be able to transit from one room to the next but they should appear naturally. Example being leaving one room on it's left side and entering the next on it's right. I'm trrying to do this via a warp system but it's flying all over my head! I've no idea where to start with this at all. With the fade script? With the fade object? With the warp object? I don't even know.
I think i get what you're after. slide out / slide in effect?
This can be set up with views and a control object. same principle as the fade object, but moving the view instead of drawing a fade.
 
E

Ealonex

Guest
I think i get what you're after. slide out / slide in effect?
This can be set up with views and a control object. same principle as the fade object, but moving the view instead of drawing a fade.
Aha no, I was going to do that once I've learned message boxes and cutscenes of sorts. I think I know how to do that on my own. My problem is that as of when you first helped me, I had only a start menu and a beginning room. Now, I'm trying to connect this beginning room(rm_forest_start) to rm_forest1. I figured I'm supposed to use a transparent Warp tile in order for this to work, but I have had no luck after trying for a couple of hours.

edit: also, control object? no tutorial i've checked out ever mentioned anything like that.
 
Last edited by a moderator:
E

Ealonex

Guest
still stuck on this :(
Vague idea is that I have a warp and a start object and I can edit it via creation code so that it knows where the player was before or something like that. No idea how to code it though.
 
P

PlayLight

Guest
Sorry bud, totally missed your previous message.
You might be interested in a video of Shaun (Lord of the GMC) Spalding's, which goes over this topic in detailed steps.
Level Warp / Changing Rooms
Wow!! that text was bigger than i expected.
 
Top