lengthdir_y(len, dir);
Argument | Description |
---|---|
len | The length away of the point to return. |
dir | The direction of the point to return. |
Returns: Real
This function seems confusing at first, but it's not really. It
is used to get the y component of a position "len" pixels from the
starting point and in direction "dir". Imagine a circle around your
instance, then imagine a point anywhere on that circle. To move to
that point we need to move the object so many pixels in that
direction... so this function (when used with lengthdir_x) gets the position of
that point on the circle to be used in code by the instance. See
the image below for details:
instance_create(x + lengthdir_x(64, image_angle), y + lengthdir_y(64, image_angle), obj_bullet);
This will create a bullet instance at (x,y), but with 64 pixels added in the direction of image_angle. This is typically used for syncing a bullets start position with the end of a gun in game.