Sprites in GameMaker control the actual pixels displayed on screen. In this video learn how to use GameMaker's Image Editor to draw our first sprite.
- [Voiceover] The first object we create for our game is the paddle that moves left and right across the screen. Before we create the actual Object for the paddle, let's create the graphic, or Sprite. We're going to use GameMaker's built-in Sprite Editor for this. First let's create the resource by right-clicking the Sprites folder and choosing Create Sprite. This automatically opens up the Sprite Properties. I'm going to maximize this window, and then I'm going to rename this Sprite using our naming convention. In this case, since it's a Sprite, the prefix will be spr_ and then the unique name can be paddle.
To get to the Sprite Editor, we need to click the Edit Sprite button. This is where we create the new image. Go to File, New. We're going to choose the dimensions of our paddle, so it's going to be wider than it is long, so it will be 160 in the Width, and 16 in the Height. And then we choose OK, and now we see a transparent rectangular image. To edit this image, we have to double-click it, and now we're presented with some standard drawing tools. Under the Tools menu, we could use the rectangle tool.
Under Colors we can choose a color of green. And then draw a rectangle starting at the top left and dragging down to the bottom right. But notice only the border of the rectangle is green. That's because we only set the Left color to green. The Right color is still set to white. Instead of creating a new rectangle and using a different fill color, we'll use a new tool. We'll use the paint bucket. And now we can left-click to fill our rectangle with the color green. To make our image more interesting, let's go to the Image menu.
You'll see some effects at the bottom including a Glow, Buttonize, and Gradient Fill. We're going to choose Gradient Fill. In this menu we see the Original, and then the New. A Gradient Fill uses two different colors. In this case, the default is black and white. We'll change that to be two shades of green. We have different options for the kind of Gradient Fill. I'm going to choose the second-to-last in the first row. You can choose whatever you think looks best. And to make this change we click OK.
Let's make one more change to give our image a bit of a 3-D look. Under the Image menu again, this time choose Buttonize. Normally this is used in UI elements, to create buttons. But I think it will look great for our paddle. For Opacity, we can drag to increase to 200. To get it just right, we can type it in. The thickness looks better at five, so we'll choose five. You could smooth the edges, but let's leave that unchecked and choose OK. To save the new image, we click the green check-mark in the top left of the Image Editor.
Note that this Sprite only has one frame. One image. We could create additional images to create an animation but we'll do this in a later video for another Sprite. For now, just click the green check-mark to close the Sprite Editor and save our changes. Lastly, we're going to want our paddle to have some collision. For this, we're going to need to modify the collision mask, So click the Modify Mask button. Currently, the Bounding Box is set to Automatic, so the collision mask covers the entire Sprite. That's why our image appears a bit darker here.
If we wanted to, we could manually set the dimensions of the bounding box. For example, we could set the Left to 50, and now notice the collision mask have moved a bit to the right. For our purposes, we'll just explicitly set the bounding box to be Full image, which also covers the entire image. And we'll leave the shape set to Rectangle, and choose OK. In GameMaker, you can choose the Origin point of each Sprite. In the case of the paddle, we want the Origin to be in the center, so in the Origin area we're going to select Center, which will set the X to 80 and the Y to 8.
Finally, to save the Sprite, and to close the Sprite Properties, we'll click OK. And we'll notice our new Sprite appears under the Sprites folder in the resource tree. Now that we've created our first Sprite resource for the paddle, we can create the paddle Object. We'll cover that in the next video. For now, just make sure to save your project.
- Creating a new GameMaker project
- Creating sprites
- Importing existing images
- Adding collisions
- Playing sounds
- Designing game levels
- Creating start and game over screens
- Exporting the game