Building the Map

Now that we have all the pieces, building the map becomes a piece of cake. It is an essential part of the 2D game environment because this is what defines your gamespace - or the area that the player interacts within.

Start by placing an ACSpriteMenuBlock (9-slice it if you didn't in Chapter 2, Working with Assets), and remember to change the Draw Mode into Sliced. Then, stretch it until you have something like this:

Next, drag the walls into the map, and stretch them as required. (Remember to keep the sliced mode! As a result, you won't stretch the scale). Duplicate the pieces as required, until you will reach something like the following:

Once you finished working on the walls, I suggest you place them inside an empty game object to keep your scene tidy.

Also, you will need to create four walls to enclose the map. However, you need to remove the Sprite Renderer component, so that the map looks exactly like before, but the player cannot run away from the map.

Before we move on, we need to select them all and attach a BoxCollider2D to all of them. At the moment of writing, there is a bug, since the BoxCollider2D won't stretch to fit the dimensions of the wall (since it is a sliced sprite). Until this bug is fixed, I suggest you use this free script that you find at the following URL: http://player26.com/?p=1363.

The script is super easy to use: just select all the walls, and attach the script to them. The script will fix the collider, and it will delete itself. Simple, isn't it?

The next step is to place all the cakes on the map. If the Audio icon is bothering you, you can scale all the gizmos icons to zero from the Gizmos tab in the Scene View. Once you have placed all the cakes around the map, you should have something like this:

Once again, you can create an empty game object in which to parent all the cakes, so to keep the scene tidy.

The final touch is to add the player and playtest your game so far. The character might be too big to fit the corridors we have created, so scale it as needed.

..................Content has been hidden....................

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