sprite_get_yoffset

Finds the yoffset of a sprite.

Syntax:

sprite_get_yoffset(index);


Argument Description
index The index of the sprite to find the yoffset of.


Returns: Real


Description

When you define a sprite in the sprite editor, you need to set the origin for that sprite. This is the point at which the sprite will be "attached" or "drawn" when used with an instance. This function returns the relative offset for the y-axis of the origin based on the upper left corner being the 0,0 position, with a +y being down and a -y being up from this. The following image illustrates this:


Example:

if y - sprite_get_yoffset(sprite_index) < 0
   {
   y = sprite_get_yoffset(sprite_index);
   }

The above code will ensure that an instance is maintained within the room based on the sprite (so the sprite is always visible).


Back: Sprites
Next: sprite_get_bbox_bottom
© Copyright YoYo Games Ltd. 2018 All Rights Reserved