problem with my room transition

M

Meve

Guest
Hi!
I've been following the 2d platformer tutorial by Shaun Spalding and im currently ont he part of room transitions.
i have a problem when I start the game: it says I havent set the variable for
if (mode != TRANS_MODE.OFF)
in this code:
Code:
if (mode != TRANS_MODE.OFF)
{
    
    if (mode == TRANS_MODE.INTRO)
        {
        percent = max(0,percent-0.05);
        }
    else
        {
            percent= min(1,percent+0.05);
        }
    
    
}


if (percent == 0) or (percent == 1)
{
    
    switch (mode)
    {
    
        case TRANS_MODE.INTRO:
        {
            mode= TRANS_MODE.OFF;
        break;   
        }
        
            case TRANS_MODE.NEXT:
            {
            mode = TRANS_MODE.INTRO;
            room_goto_next();
            break;   
            }
                case TRANS_MODE.GOTO:
                {
                mode = TRANS_MODE.INTRO;
                room_goto(target);
                break;   
                }
                    case TRANS_MODE.RESTART:
                    {
                    game_restart();
                    break;   
                    }
                            
    }
    
}
this is in my create event:
Code:
w = display_get_gui_width();
h = display_get_gui_height();
h_half = h * 0.5;
enum TRANS_MODE
{
    
    OFF,
    NEXT,
    GOTO,
    RESTART,
    INTRO
    
}

percent= 1;
target = room;
and this is in my draw GUI event.
Code:
if (mode != TRANS_MODE.OFF)
{
    
    draw_set_color(c_black);
    draw_rectangle(0,0,w,percent* h_half,false);
    draw_rectangle(0,h,w,h-percent * h_half, false);
}
draw_set_color(c_white);
draw_text(50,50,string(percent));
does anyone know where I have made a mistake?
 
Top