New Draw Events in GameMaker (GMS 1.3+)

After updating GameMaker: Studio to the 1.3 version, you'll find that you have a few new Draw Event types to use when creating your games. These have been added to increase the flexibility of the draw event and help streamline the graphics pipeline, which in turn will optimise your game. In total, there have been 6 new events added: Pre and Post draw events, and then Begin and End events for both the standard draw event and the GUI draw event.

Event Order

One of the most common requests from users of GameMaker: Studio is for more control over event timings, particularly with how things are drawn, which is one of the reasons these new event types have been added. Let's take a look at how they are triggered and in what order.


The above diagram illustrates the flow of events each step of the game. As you can see, this new event set-up gives you far more flexibility when it comes to how and when things are drawn to the screen, making "layering" of sprites and images from multiple objects easier, as well as giving far easier methods for the creation of post-draw effects and other things that would previously have required the use of multiple surfaces and careful depth ordering.

Draw Begin and Draw End Events

You now have three standard draw events and three GUI draw events to use. These extra events function the same way as the Begin and End Step events, ie: they are triggered every step of the game and will always be triggered in the same order - begin, standard, end. For the normal draw events, these will be triggered once per step for all instances in the room, so all instances will have perform the Draw Begin, then all instances will perform the standard draw, then all instances will perform the Draw End. And this will happen for each visible view.

This means that you can now use a single object to (for example) set the draw colour and fonts in the draw begin event, and be certain that all instances in the room will use these values in the standard draw event. You can also use these events for easy "layering" images without having to worry about depth conflicts between instances drawn at the same depth. For example, you can have all your instances draw shadows in the Draw Begin, then draw their sprites in the standard draw then finally draw any special effects in the Draw End and you can be sure that everything will look correct. This is illustrated in the following image:


On the left, we have each instance at the same depth and only using the standard Draw event, with three lines of code for drawing the shadow, the sprite, and the overlay effect. On the right, however, we have split these three lines over the three events, with the shadow code  in the Draw Begin and the overlay code in the Draw End event. We don't even need to add the standard Draw event now, as it will default draw the sprite for us (note that this is only true of the standard Draw event as the new events will not default draw anything if they have no code or comments).

Draw GUI Begin and Draw GUI End

These events are pretty much the same for the GUI drawing as they are for the standard drawing, however they are not affected by views, and so will only be triggered once per game step (unlike the standard draw events which are triggered once for each view). They are also governed by the size of the GUI layer itself, and not the screen/display size, nor the view ports etc...

Pre and Post Draw Events

Currently you can draw to the screen (or a view) and you can draw to the GUI layer, but now the Pre and Post draw events give you the ability to draw directly to the back buffer. What's that? Well, if you have ever turned off the background colour in the room editor in GameMaker: Studio you will have seen something like this:


This happens because normally GameMaker will clear the back buffer then draw to it before this is displayed in the window to the user. However if you remove the clear function, then you can see what was drawn to the screen in the previous frame. that's all fine and well, but what use is it? Well, previously, not much except to give your game some nice "trippy" effects, but with the addition of the Pre and Post draw events, you can now do much more!

Pre Drawing

With the Pre draw event, If you switch of the background clear in the Room Editor (and you switch it off for views too if you use them), then you can take control of when the screen is cleared and what is drawn to it before the game draws anything else, meaning that you can create background effects and "catch" the contents of the buffer to manipulate before continuing. Note that this event is not view or even GUI resolution specific, but will be the size of the combined screen space for all views currently visible, or the window size if only using one view or none at all. The image below illustrates this


As you can see, we have two active views here, so the back buffer is the combined size of the visible window and we are using it to draw some coloured lines before drawing the rest of the game elements. So, if you are using the Pre draw event, you are drawing to the full screen render target which will have the same size as the window to which all views are made to fit.

Post Draw

The Post draw event is triggered after the standard draw events, but before the draw GUI events. Like the Pre draw event, it is based on the size of the back buffer, and is placed before the draw GUI events to enable you to perform post-processing effects and other things on a full screen basis simply and easily without interfering with any HUD/GUI elements that you may have in your game.

This type of thing would normally require that you assign a view to a surface, then scale this surface up to the screen size and manipulate that, but this event simplifies the process by permitting you to manipulate directly the contents of the screen buffer. Obviously that's just one example of how this new event can be used, so take some time to experiment and see what else you can do here!


The addition of these new events to the Draw Event category is, without doubt, a big change over previous GameMaker versions. They greatly increase the ease with which you can create graphics effects, and they give you multiple new options for choosing how, and when, to draw what you want to the screen. They should also help increase your work-flow as well as help optimise your games by permitting easier depth control, more obvious and simpler coding practices and easier fullscreen post draw effects.

Finally, to give you a starting point for getting to grips with these changes, you can download a very basic demo project from this link. Have fun!

Have more questions? Submit a request


Article is closed for comments.