Drawing Sprites And Backgrounds

This section contains all the functions available for drawing the graphics assets.

Even though you can set up backgrounds in the room editor and you can assign sprites to instances, often this is not flexible enough for the game you are making. For example, if you have an instance that has to draw a menu, you may want to display various button sprites at a time, or if you have a game with scrolling parallax backgrounds you will need to be able to set them through code in a controller instance of some type. In these situations you should be using the following functions which can draw sprite and background assets anywhere in the room with some of the functions also permitting you to manipulate the shape, size, colour and alpha of the sprite to achieve special effects.


You can assign a sprite to an instance and by default GameMaker: Studio will draw it with the properties given by the various sprite variables, however if you add anything into the draw event, you are "taking control" and must tell GameMaker: Studio exactly what to draw. This means that if you must use the following functions to define exactly what it is the instance is to draw and where about in the room it is to draw it:

  1. draw_self
  2. draw_sprite
  3. draw_sprite_ext
  4. draw_sprite_general
  5. draw_sprite_part
  6. draw_sprite_part_ext
  7. draw_sprite_stretched
  8. draw_sprite_stretched_ext
  9. draw_sprite_pos
  10. draw_sprite_tiled
  11. draw_sprite_tiled_ext

If you are using SWF format sprites, then there are also additional options for controlling the anti-aliasing used when drawing (see Importing Vector Images for more information on these types of sprites). Note that these functions work on a global level and will set the AA on all vector SWF sprites drawn after they have been called.

  1. draw_enable_swf_aa
  2. draw_set_swf_aa_level
  3. draw_get_swf_aa_level

Apart from those functions listed above, there are also two special functions designed for use with skeletal animations (see Importing Skeletal Animations for more information on these types of sprites, and the section Skeletal Animations for specific functions related to these types of sprites):

  1. draw_skeleton
  2. draw_skeleton_collision
  3. draw_skeleton_time


Although the Room Editor Backgrounds Tab has a number of options for setting up backgrounds, it is often more useful to draw them using code. To that end, GameMaker: Studio has the following functions that permit you to draw background assets in a number of different ways:

NOTE: Don't forget that adding any code into the draw event of an instance will switch off the automatic drawing of the sprite for that instance, so if you need to draw the sprite and a background you should use the functions above in combination with those listed here.

  1. draw_background
  2. draw_background_ext
  3. draw_background_part
  4. draw_background_part_ext
  5. draw_background_stretched
  6. draw_background_stretched_ext
  7. draw_background_tiled
  8. draw_background_tiled_ext
  9. draw_background_general

Back: Drawing
© Copyright YoYo Games Ltd. 2018 All Rights Reserved