1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GM:S 1.4 Fade in draw event

Discussion in 'Programming' started by Sk8dududu, Mar 3, 2019.

  1. Sk8dududu

    Sk8dududu Member

    Joined:
    Aug 14, 2017
    Posts:
    198
    I'm using a controller to draw sprites at different places and sizes in a room as a tutorial. It has a lot of different sprites to draw and they all have to be different scale then they are in the regular game, so in the draw event I'm using draw_sprite_ext, but unlike a step event, I'm unable to use the +=0.05 for the image_alpha to fade in the sprite. Is there an easy way around this without having to create a step event or a different variable every time I want to fade something in at a different rate? The below is what ideally I would like to use, but it doesn't allow for that += in that function.

    Code:
    if draw = 1
        {
        draw_sprite_ext(spr_information,0,270,480,0.5,0.75,0,c_white,+=0.05);
        draw_set_font(font_points);
        draw_set_colour(c_white);
        draw_text(200,200,"Welcome to#(insert game name)#Tutorial");
        }
     
  2. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    463
    Replace that += 0,5 for a variable tgat increase that amount per step, and reference that variable instead.
    Or an even better way in the long run is you could make a script with following arguments
    scr_fade_in(spr_sprite_name, x, y, fade_in_rate); and just call it whenever you need it.

    Edit: On a more intermediate level, if you feel comfortable with maths a bit, you could check out tweening functions if you want to fade in/out in a more dynamic/non-linear way, once you get the basics down.
     
    Sk8dududu likes this.
  3. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    2,012
    Well I could go about why the += doesn't work there but I'm not sure if you don't already understand it and wrote it out just to demonstrate your intent (but basically you'd be dreaming up information where none exists). You need to make that information real, which as explained above is by declaring a variable that gets adjusted on step event.
     
    Sk8dududu likes this.
  4. Sk8dududu

    Sk8dududu Member

    Joined:
    Aug 14, 2017
    Posts:
    198
    Thank you both. I had actually tried a variable earlier but I vimhess I made a mistake because it didn't work last time, but I tried again after reading the above suggestion and it was fine. All fine now, much more simple than I had thought it would be.
     

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