Creating Sprites

Now that you know what a program is, it's time to look at some of the different assets that can be used in GameMaker to make your game. To start with, we'll look at sprites, which are generally one of the first things you'll need when making any project. As explained in the section on The Asset Browser, a sprite is an image that can be animated (although it doesn't have to be) and then drawn to the screen. In general a sprite will be associated with an object, but you can draw sprites on their own, either from code or in the room editor Asset Layer (we'll talk about this in more detail later, in the section on rooms). You can also create a sprite to be used as a tile sets, but we'll explore that option in a later section too.

When you create a new project from the Start Page, the asset browser will only contain empty folders for the resources you may need, so you need to right-click Icon RMB on the sprite asset folder and then select the option Create (if you don't have a sprite asset folder you can make one from the right-click menu and then create the sprite, or you can simply right-click anywhere in the asset browser and create it). This will create a new sprite asset and open The Sprite Editor for you (if the sprite editor does not open, simply double-click LMB Icon on the new asset):

The Sprite EditorAs you can see, the top left of the window has a field for the Name of the sprite. All sprites (and all other assets) must have a name given to them so that you (and GameMaker) can identify them easily, although you should note that this name is really just a variable which holds an ID value that "points" to the resource, in this case a sprite. It's best to give each sprite a descriptive name so that you can identify at a glance whether a particular asset is a sprite or an object or something else, and many people do this by prefixing or suffixing the resource with the letters " spr" - for example, " spr_Ball". Note that resource names are limited to using only letters, digits and the underscore symbol "_", and the name of all assets must start with a letter, not a number.

The other features of the sprite editor we'll discuss at the end of this section, but first we need to explain how to draw a sprite. This is done in The Image Editor. The image editor is a very powerful tool for creating the graphics in your game and is opened by clicking the Edit Image button.

The Image Editor

We won't go into too much depth about the tools available here - for that we have the Image Editor section of the manual - but briefly you have:

Draw something into the image editor and take some time to play with the options, then when you are ready close the image editor workspace (which will save the image) to take you back to the main workspace with the sprite editor in it. We'll discuss a few other features of the sprite editor that are important to know when just getting started...

The first thing you need know is how to set the origin for the sprite. The origin is simply the point that will be used to "anchor" our sprite within the room, and in this case we want to set it to the centre.

So we click LMB Icon on the from down menu for setting the origin and select "middle centre":

Example Showing The Sprite Origin

You'll see the blue origin marker in the preview image move to the center of the sprite. Note that you can place the origin anywhere you wish by simply clicking LMB Icon on the preview image, and you can also manually input the origin position by adding values into the x/y fields at the top.

Another important thing to do know is how to set the collision mask for the sprite. The collision mask is the area that GameMaker will check to see if there has been a collision with any other instance of an object in the game, and by default this is set to rectangle (which is also the fastest to resolve). Note that you can set the detection mode for the bounding box to be either automatic (the default value) or manual. If you choose manual you will be able to set the bounding box values left, right, top and bottom.

Example Showing The Sprite Mask

Any type of collision mask other than rectangle will be slower to resolve, but when making a small, simple game it's not usually an issue. Note that you can also import sprites made in other software by clicking the Import button in the sprite editor, and you can also drag image files onto the GameMaker IDE to add them as sprites to the Asset Browser. You can also drag sprites from the Asset Browser to add them to things directly, in which case the IDE will highlight the places you can add the sprite to:

Where To Drop A Sprite On An ObjectIf you'd like more detailed information on the Sprite Editor and the Image Editor, please see the following sections of the manual:

You can close the sprite editor now as we are going to move on to discuss Tile Sets.