layer_background_stretch


描述

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.


语法:

layer_background_stretch(background_element_id, stretch)


参数:

参数 描述
background_element_id The unique ID value of the background element to change
stretch The stretch toggle, which can be true or false


返回:

N/A(无返回值)


例如:

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.


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