Error on flipping background

Sergio

Member
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!
 
I

innercitysumo

Guest
Just to check - are you using GMS2? That function won't work in 1.4.
 

sgtcrispy

Member
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?
 
D

Death

Guest
If you are using a sprite as background, try just reversing its x scale, using
layer_sprite_xscale, or draw_sprite_ext.
 

NightFrost

Member
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.
 
Top