direction


描述

All instances in GameMaker Studio 2 have certain "built in" properties that you can use and set to govern how they look and behave. Direction is one of those properties and can be used to set the direction of movement of the instance when the instance has a speed other than 0. Note that directions in GameMaker Studio 2 are usually calculated as 0° being right, 90° being up, 180° being left and 270° being down.


语法:

direction;


返回:

Real(实数)


例如:

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

The above code will change the direction of movement of the instance based on which key (left or right) is pressed.