This function can be used to set the speed of an animating sprite that has been assigned to a background element. You give 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 animation speed. If the IDE has set the animation speed for the sprite used to be calculated as Frames Per Game Frame, then the speed value given is a multiplier, with 1 being the default value, and setting it to 0.5 will half the animation speed, while setting it to 1.5 will double it. However, if the IDE has set the animation speed for the sprite used to be calculated as Frames Per Second, then the speed value given is a literal frames per second value, so setting this to 5, for example, will set the animation to loop 5 frames every second that the game runs. If the background element has no sprite attached or the sprite used has no sub-images, this function will have no effect.
参数 描述 background_element_id The unique ID value of the background element to change speed The speed multiplier/value to use for the element
var lay_id = layer_get_id("Background_water");
var back_id = layer_background_get_id(lay_id);
The above code will get the layer ID for the layer named "Background_water" and then use that to get the ID of the background element on that layer. This ID is then used to change the element yscale.