1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 [SOLVED] fade-in/out transition object defaulting to 0/0 in view

Discussion in 'Programming' started by Tofu Heavy Industries, Mar 1, 2019.

  1. Tofu Heavy Industries

    Tofu Heavy Industries Member

    Joined:
    Feb 2, 2018
    Posts:
    56
    I have an object that acts as black fade-in fade-out transition thingie. Whenever I use it, if the room has a view, the view in the room will be snapped back to x0 y0. I don't know why this is happening. But will retain the correct size of the view itself.

    The calling object is persistent in the room its in, with a depth of 1.

    calling line
    Code:
    instance_create(view_xview[0],view_yview[0],obj_fader);
    Object Properties: obj_fader
    Sprite:
    Solid: false
    Visible: true
    Depth: -9999
    Persistent: true
    Parent:
    Children:
    Mask:
    No Physics Object


    obj_fader: Create
    Code:
    AlphaLevel = 0;
    fade = 1;
    
    obj_fader: Draw
    Code:
    AlphaLevel = clamp(AlphaLevel + (fade * 0.05),0,1);
    
    if (AlphaLevel == 1) {
        room_goto(global.room_going_to);
        fade = -1;
    }
    if ((AlphaLevel == 0) && (fade == -1)) {
        instance_destroy();
    }
    draw_set_colour(c_black);
    draw_set_alpha(AlphaLevel);
    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);
    
     
  2. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,662
    In the Draw GUI event put

    draw_text(0,0,object_get_name(view_object.object_index));

    See what it says when the glitch happens.
     
    Tofu Heavy Industries likes this.
  3. Tofu Heavy Industries

    Tofu Heavy Industries Member

    Joined:
    Feb 2, 2018
    Posts:
    56
    I added a draw gui event to the obj_fader and added that line - no text output.
    I put that line in the regular draw event of obj_fader - no text output.

    I even put it into a persistent control object with a draw event and that didnt work.

    Additional info: the view[0] is following obj_main, which has no draw event itself, and creates an instance of obj_fader during its STEP event.
     
  4. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,662
    Put my line in the GUI event of obj_main. It MUST be in a GUI event.

    The fact you never saw anything at all suggests maybe the text was misaligned. So change the x to view_wview/2 and change y to 64.

    Do you have code anywhere that affects the view?
     
    Tofu Heavy Industries likes this.
  5. Tofu Heavy Industries

    Tofu Heavy Industries Member

    Joined:
    Feb 2, 2018
    Posts:
    56
    Active during the whole time is just :
    obj_main - player character
    obj_control - game control object

    putting that code line in either of those objects (in the draw gui event) does nothing. Well, it will show the object name of what its in (in the view as it should be), but as soon as an instance of obj_fader is created, it goes blank.

    Checking around for other view code - nothing else modifies it.
     
  6. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,662
    Wait, what? It shows the name of the following object and then shows nothing at all when obj_fader is created?! That's not right. Unless it's cuz you have the draw colour set to black so the text is just covered by the fader.

    Is the game snapping to (0,0) of the first room or the next room? The view might be trying to go outside the room. Track the coordinates of obj_main before and after the transition.
     
    Tofu Heavy Industries likes this.
  7. Tofu Heavy Industries

    Tofu Heavy Industries Member

    Joined:
    Feb 2, 2018
    Posts:
    56
    I made sure to set the font color to white.
    its snapping to the 0,0 of the room its currently in, not the room its going to.

    thanks theou - the problem was i set the x/y for obj_main to 200,96 right after creating the fader object, so it would snap there.
    I just moved the code to set obj_main x/y AFTER it enters the next room.


    im still not sure why the line of code you provided never appeared.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice