layer_background_stretch


Description

Using this function you can toggle a background element sprite to stretch to fit the room or remain at 1:1 with the resolution. You supply the background element ID (which you get when you create a background element using layer_background_create() or when you use the function layer_background_get_id()), and then set the stretch argument to true or false. When set to true the element sprite will be stretched to fit the room (either scaled up or scaled down depending on the sizes of the sprite and the room), and when set to false, the element sprite will be displayed at its native resolution.


Syntax:

layer_background_stretch(background_element_id, stretch)


Arguments:

Argument Description
background_element_id The unique ID value of the background element to change
stretch The stretch toggle, which can be true or false


Returns:

N/A


Example:

if mouse_check_button_pressed(mb_left)
   {
   var back = layer_background_get_id(layer);
   if layer_background_get_stretch(back)
      {
      layer_background_stretch(back, false);
      }
   else
      {
      layer_background_stretch(back, true);
      }
   }

The above code checks for a mouse button press and if one is detected it will toggle the stretching of the background element sprite assigned to the layer the instance running the code is on.


Back: Background Layer Functions
next: layer_background_blend
© Copyright YoYo Games Ltd. 2018 All Rights Reserved