Day 104 — Working with Tilemap
Hey and welcome!
Now that we have Tilemap integrated and working in our new project it’s time to see how we go about using it!
If you’re familiar with paint or any other image editing software the Tile Palette feature has several options you’d find in there. Instead of selecting a particular colour though you click on which tile you would like to paint with.
There’s also a few tools you can make use of that you would find in most image editing software such as the paint brush, the fill tool and the eraser in order to give you more control and speed up the process of creating a level. In the scene view you should see a white rectangle with a camera icon in the middle. This section is what your camera is currently looking at so you should see the game view update as you paint in tiles here:
Another cool thing you can do is to click and drag your mouse over several tiles in your palette which you can then paint all at once.
As you can see from the above as well you can also paint over tiles and replace them with your current tile selection from the palette, it’s a pretty streamlined tool so far! Go ahead and fill out your ground and in in a crater for the player to jump over for good measure so that you have something like this:
Now let’s work on really taking advantage of what the Tile Palette can offer us. Create a new palette and this time call it Caverns and save it somewhere appropriate. In the assets you’ll find a Black_Cavern_2 image under Environment > Black_Cave.
Switch this to a sprite texture type if it isn’t already and then proceed to do the same you did for the Ground image by changing the sprite mode to Multiple, opening up the sprite editor and slicing the sprite by cell size of 128 x 128 and then setting the pixels per unit to 128 as well.
Once done drag and drop that into your Caverns palette and you’ll have 2 palettes now that you can switch between! Pretty handy so far but there’s more that can be done. Now it’s time to find the Far_Cavern image under Environment > Far_Cavern and then do the same stuff you’ve done before except this time split it up by 256 x 256.
Now find the Gray_Cavern image under Environment > Gray_Cavern and split it up to 128 x128 this time. Let’s get to the fun part now, with both of those images edited into sprites go ahead and drag and drop both of them straight into your cavern palette and save.
That’s right, not only can we switch between different palettes for different parts of the environment but we can also put multiple sprites into the same palette to make use of them! If you need to adjust their position in the palette you can click on the Edit button, then select what you want to move with the Selection tool before moving it with the Transform tool.
I hope you’re enjoying Tilemap as much as I am right now!