Creating a spawn point

Let's add a sprite where we can spawn the enemies from. This is the starting point of the tower defense. In the Insert New Object window, double-click on Sprite to add a sprite, as shown in the following screenshot:

Creating a spawn point

Once you have added the sprite, resize it to 32 by 32, as shown in the following screenshot. This way, it will easily fit the grid that we have made. Click on the resize button; it looks like a double arrow and can be found at the top of the window.

Creating a spawn point

Once you have resized the image, fill it with a color—for this example, we're going to use green. Make sure that this color stands out. When you are building the basics of your game, you shouldn't worry too much about the artwork. Games are more about functionality than art. This won't be the final product but it will serve us for now.

Creating a spawn point

Close out of the box and move the sprite around. You should see that the square does move around in a grid pattern. This means that it jumps from location to location quite easily. The only problem is that the grid seems to be a bit off. This is because the origin is in the center of the object. We need to change the origin to the side.

Double-click on the object and click on the Origin tool. As you can see in the following screenshot, the origin is in the center:

Creating a spawn point

Move the origin to the side, as shown in the following screenshot:

Creating a spawn point

We can now have a good grid placement for our object. Your project should look something like the following screenshot:

Creating a spawn point

There is one more thing we need to do: we need to change the name of the sprite to something that makes more sense. We changed the name to Start, as shown in the following screenshot:

Creating a spawn point

Next, we need to duplicate the sprite for the end. Right-click on the sprite and select Clone object type, as shown in the following screenshot. When you clone an object, you create a copy of the object to use in the game. Note that this makes an entirely new object with a new name. You cannot do this with the copy-and-paste method; when you copy-and-paste, you copy-and-paste the same object.

Creating a spawn point

You should now have another object. Place it outside the game area, as shown in the following screenshot:

Creating a spawn point

Click on this object and give it a new color. We gave it a pink color by using the paint bucket tool, as shown in the following screenshot. Now, you should see that the sprite is pink. Change the name of the game object to End.

Move the sprite to a place where you want your goal to be, as shown in the following screenshot:

Creating a spawn point
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.133.61