speed


描述

All instances in GameMaker Studio 2 have certain "built in" properties that you can use and set to govern how they look and behave. speed is one of those properties and defines how many pixels the instance will move every step. Unlike hspeed and vspeed, speed has no direction associated with it as this is governed by the direction value of the instance, but it can have a negative value, in which case the instance will travel in the opposite direction to that set by the direction function (ie: direction - 180°).


语法:

speed;


返回:

Real(实数)


例如:

if keyboard_check(vk_up) speed = 2;
if keyboard_check(vk_left) direction += 5;
if keyboard_check(vk_right) direction -= 5;

The above code will use the arrow keys to set the speed and direction of the instance.