GMS 2 Set Blendmode for layers?

Discussion in 'Programming' started by William Garrison, Sep 11, 2019.

  1. William Garrison

    William Garrison Member

    Joined:
    Apr 16, 2019
    Posts:
    33
    Hey friends. Okay so here is what I am after. I know how to set the blendmode of a specific object using the below code. But I want to, and am trying to, apply the same "Add" blendmode to a specific Tiled Layer or the sprite asset itself. Whichever works. Here is what I tried with zero positive results.

    Code:
    C1 = layer_get_id("Clouds_L1");
    
    if (C1)
    {   
        gpu_set_blendmode(bm_add);
        draw_self();
        gpu_set_blendmode(bm_normal);
    }
     
  2. Mike

    Mike nobody important GMC Elder

    Joined:
    Apr 12, 2016
    Posts:
    2,327
    Look at "layer_script_begin()" and "layer_script_end()", and stick your blend stuff there.
     
    Bentley and Binsk like this.
  3. William Garrison

    William Garrison Member

    Joined:
    Apr 16, 2019
    Posts:
    33
    Ooh thanks friend. I am reading up on that now. :)
     
  4. William Garrison

    William Garrison Member

    Joined:
    Apr 16, 2019
    Posts:
    33
    BoOm! Worked like a charm. :p Here is the final code I used...Pretty simple. AND I learned something. FYI the clouds at the top were was I was getting to ADD / Overlay...

    I tried to upload a gif of him running around, but couldn't get file size small enough.
    Grimli-ADD-Harvest-HobbyHaus.png

    Set up two scripts...
    START
    Code:
    if event_type == ev_draw
       {
       if event_number == 0
          {
            gpu_set_blendmode(bm_add);
          }
       }
    END
    Code:
    if event_type == ev_draw
       {
       if event_number == 0
          {
            gpu_set_blendmode(bm_normal);
          }
       }
    Then in the Room Creations > CREATE
    Code:
    C1 = layer_get_id("Clouds_L1");
    
    layer_script_begin(C1, scAddStart);
    layer_script_end(C1, scAddEnd);
     

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