|
The following video walks you through how to edit the properties of a level.
Dim lights
Embed Embed this video on your site
Transcript for low bandwidth users:
Hi! Welcome to the second level editing tutorial to the Platformer Starter Kit.
Last time, I walked you through how to open up a level with Tiled, and to place tiles on the screen. However, you may have wondered, how does the game know what each of these tiles is supposed to do? Today I'm going to show you exactly that.
Most of the content for a game using PushButton Engine is defined in XML level files, and Platformer Kit games are no exception. Every level in the game has its own XML file, and the blank starter level's XML file can be found in Assets -> Levels -> starter_area_1.xml. Go ahead and open that up.
Now there's a lot in this level, and it can be somewhat overwhelming, but I'll try to summarize that a lot of this is just glue that ties the information in the tilemap (created in Tiled) with the images to use, as well as the behavior defined in code.
If you aren't familiar with Entities or level files in PushButton Engine, I recommend that you go over to their site and watch and read the tutorials on them -- fully explaining how entities work is covered well in other places outside of this video.
The Background entity has a couple of properties that interest us. For one, it defines the levelData filename that tells this level which tile map .tmx file to load for each layer.
It also has a tileMapCollision field that looks like a big messy grid of characters. This is what defines how each tile type should behave.
It might look confusing at first, but I'll try and explain it, and hopefully it will make sense for you.
First, take a look at the tile set. It's 10 tiles wide, by 14 or so tiles high. Now look at the grid of text in the tileMapCollision field -- you'll notice that it's the same dimensions. Each character in the tile map corresponds to a tile in the tile set graphic, and indicates how that tile acts. There are four kinds of tiles:
X's indicate solid tiles that the player can stand on, and can't walk past. .'s indicate empty tiles that the player can pass through without effect @'s are death tiles, that kill the player on contact ^'s (carets) are one-way platforms, that the player can jump up through or walk past, but the player can stand on it if they fall down on to it.
So to experiment, try putting one of each of these tiles in the example level. A solid tile, a blank tile, a one-way platform, and finally some death tiles. For good measure, add some spikes too -- they don't do anything, they're just decoration.
Rebuild and run the game, and you can see the tiles in use.
Now let's change some around. You can also try changing these around, and changing the behavior of the tiles. For starters, let's go ahead and make these spikes deadly. Find the tile that you want to change -- in this one, the big gray spike is the 9th row down, and 8th column over. Count the same number of characters on your tileMapCollision field and change the "." to a "@". Save, recompile, and run again. Now walk into the spikes, and you'll see your character react accordingly.
Congratulations, you have finished the second level editing tutorial for the Platformer Starter Kit. Thanks for watching!
|