Error on flipping background

Discussion in 'Programming' started by Sergio, Mar 1, 2018.

  1. Sergio

    Sergio Member

    Joined:
    Aug 9, 2017
    Posts:
    51
    Hi there:

    I'm trying to flip the brackground of my game, using this code:

    Code:
    var lay_id = layer_get_id("bg_wall");
        var back_id = layer_background_get_id(lay_id);
        layer_background_xscale(back_id, -1);
    
    Aparently, this should works, since it's the same code that appears in the manual, and there is not much to do with it, but, when I run it, I start to receive in the console the error:

    Error attempting to draw sprite spr_background


    That happens with all negative values of layer_background_xscale. If I try with 0.5, everything goes ok.


    Thanks in advance!
     
  2. innercitysumo

    innercitysumo Member

    Joined:
    Sep 24, 2016
    Posts:
    65
    Just to check - are you using GMS2? That function won't work in 1.4.
     
  3. Sergio

    Sergio Member

    Joined:
    Aug 9, 2017
    Posts:
    51
    Yes, GMS2. It wouldn't work in any way if don't ;)
     
    BattleRifle BR55 likes this.
  4. sgtcrispy

    sgtcrispy Member

    Joined:
    Jun 20, 2016
    Posts:
    2
    Sorry for the old post bumping, but I also seem to be running into this issue in GMS2 2.2.1.375.
    Code:
    CREATE EVENT:
    var lay2 = layer_get_id("BG_Elevator_Light_2");
    var back2 = layer_background_get_id(lay2);
    layer_background_yscale(back2, -1);
    
    var lay3 = layer_get_id("BG_Elevator_Light_3");
    var back3 = layer_background_get_id(lay3);
    layer_background_xscale(back3,-1);
    
    var lay4 = layer_get_id("BG_Elevator_Light_4");
    var back4 = layer_background_get_id(lay4);
    layer_background_xscale(back4, -1);
    layer_background_yscale(back4, -1);
    
    Using animated vs static images doesn't seem to matter and using any negative value causes this error.

    Error attempting to draw sprite bg_area04_EL2
    Error attempting to draw sprite bg_area04_EL3
    Error attempting to draw sprite bg_area04_EL4
    repeating over and over.

    A GMS2 bug perhaps?
     
  5. Death

    Death Member

    Joined:
    Aug 8, 2018
    Posts:
    81
    If you are using a sprite as background, try just reversing its x scale, using
    layer_sprite_xscale, or draw_sprite_ext.
     
  6. NightFrost

    NightFrost Member

    Joined:
    Jun 24, 2016
    Posts:
    1,948
    Make sure you're not mixing up background and sprite layer stuff. GMS2 makes a separation between the two and trying to use any layer_background_* and layer_sprite_* things interchangeably will lead to problems.
     

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