Sprites and images

Each object has a sprite associated with it. This is either a single image or it consists of multiple images. For each instance of the object the program draws the corresponding image on the screen, with its origin (as defined in the sprite properties) at the position (x,y) of the instance. When there are multiple images, it cycles through the images to get an animation effect. There are a number of variables that affect the way the image is drawn. These can be used to change the effects. Each instance has the following variables:
visible If visible is true (1) the image is drawn, otherwise it is not drawn. Invisible instances are still active and create collision events; only you don't see them. Setting the visibility to false is useful for e.g. controller objects (make them non-solid to avoid collision events) or hidden switches.
sprite_index This is the index of the current sprite for the instance. You can change it to give the instance a different sprite. As value you can use the names of the different sprites you defined. Changing the sprite does not change the index of the currently visible subimage.
sprite_width* Indicates the width of the sprite. This value cannot be changed but you might want to use it.
sprite_height* Indicates the height of the sprite. This value cannot be changed but you might want to use it.
sprite_xoffset* Indicates the horizontal offset of the sprite as defined in the sprite properties. This value cannot be changed but you might want to use it.
sprite_yoffset* Indicates the vertical offset of the sprite as defined in the sprite properties. This value cannot be changed but you might want to use it.
image_number* The number of subimages for the current sprite for the instance (cannot be changed).
image_index When the image has multiple subimages the program cycles through them. This variable indicates the currently drawn subimage (they are numbered starting from 0). You can change the current image by changing this variable. The program will continue cycling, starting at this new index. (The value can have a fractional part. In this case it is always rounded down to obtain the subimage that is drawn.)
image_speed The speed with which we cycle through the subimages. A value of 1 indicates that each step we get the next image. Smaller values will switch subimages slower, drawing each subimage multiple times. Larger values will skip subimages to make the motion faster. Sometimes you want a particular subimage to be visible and don't want the program to cycle through all of them. This can be achieved by setting the speed to 0 and choosing the correct subimage. For example, assume you have an object that can rotate and you create a sprite that has subimages for a number of orientations (counter-clockwise). Then, in the step event of the object you can set
{
  image_index = direction * image_number/360;
  image_speed = 0;
}
depth Normally images are drawn in the order in which the instances are created. You can change this by setting the image depth. The default value is 0, unless you set it to a different value in the object properties. The higher the value the further the instance is away. (You can also use negative values.) Instances with higher depth will lie behind instances with a lower depth. Setting the depth will guarantee that the instances are drawn in the order you want (e.g. the plane in front of the cloud). Background instances should have a high (positive) depth, and foreground instances should have a low (negative) depth.
image_xscale A scale factor to make larger or smaller images. A value of 1 indicates the normal size. You must separately set the horizontal xscale and vertical yscale. Changing the scale also changes the values for the image width and height and influences collision events as you might expect. Changing the scale can be used to get a 3-D effect. You can use a value of -1 to mirror the sprite horizontally.
image_yscale The vertical yscale. 1 is no scaling. You can use a value of -1 to flip the sprite vertically.
image_angle The angle with which the sprite is rotated. You specify this in degrees, counterclockwise. A value of 0 indicates no rotation. image_alpha Transparency (alpha) value to use when drawing the image. A value of 1 is the normal opaque setting; a value of 0 is completely transparent.
image_blend Blending color used when drawing the sprite. A value of c_white is the default. When you specify a different value the image is blended with this color. This can be used to colorize the sprite on the fly. bbox_left* Left side of the bounding box of the instance in the room, as defined by its image (taking scaling into account).
bbox_right* Right side of the bounding box of the instance in the room.
bbox_top* Top side of the bounding box of the instance in the room.
bbox_bottom* Bottom side of the bounding box of the instance in the room.
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)