layer_get_vspeed


描述

You can use this function to retrieve the vertical speed (in pixels per game frame) of the layer within the currently scoped room. You supply the layer ID (which you get when you create the layer using layer_create()) or the layer name (as a string - this will have a performance impact) and the function returns a real number for the vertical speed, where a positive value is down and a negative value up. Default is 0 (unless set in the room editor).


语法:

layer_get_vspeed(layer_id)


参数:

参数 描述
layer_id The unique ID value of the layer to get the vertical speed from


返回:

N/A(无返回值)


例如:

var lay_id = layer_get_id("Sprites");
if layer_get_hspeed(lay_id) != 0 || layer_get_vspeed(lay_id) != 0
    {
    layer_hspeed(lay_id, 0);
    layer_vspeed(lay_id, 0);
    }

The above code checks the given layer horizontal and vertical speeds and if they are not both set to 0 then it is sets them to 0.


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