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