sprite_get_yoffset


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:


Syntax:

sprite_get_yoffset(index);

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


Returns

Real


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).