speed

The speed of the object.

Syntax:

speed


Returns: Real


Description

All instances in GameMaker: Studio 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 it 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°).


Example:

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.


Back: Moving Around
Next: x
© Copyright YoYo Games Ltd. 2018 All Rights Reserved