Create Platforms
This part of the tutorial explains how to add platforms to the game. This provides the player with some solid ground to move across and jump between.
You'll learn how to:
- Create Tiled Sprite objects.
- Make a platform behave like a platform.
Series
You are reading Part 3 of the Platformer Tutorial.
- Part 1: Getting started
- Part 2: Create a Playable Character
- Part 3: Create Platforms
- Part 4: Animate the Playable Character
- Part 5: Add Collectible Coins to the Game
- Part 6: Add Enemies to the Game
- Part 7: Make Enemies Kill the Player (and the Player Kill the Enemies)
- Part 8: Add Checkpoints to the Game
Step 1: Create an object
The first step is to create an object for the platform. If you followed the first and second parts of this tutorial, this is a similar -- but not identical -- process.
The main difference is that this object needs to be a Tiled Sprite object. This type of object "displays an image repeated over an area." It's ideal for something like platforms, which are typically constructed out of small, square images (also known as tiles).
To create an object for the platform:
- In the Objects panel, click Add a new object.
- Select Tiled Sprite.
- In the Object name field, type "GrassPlatform".
- Click Select an image.
- Click Choose a new image.
- When the file chooser opens, select the "grassHalfMid" asset.
- Click Apply.
Then drag some instances of the object into the scene and vary the width of these instances to create platforms of different lengths.
Step 2: Add a behavior to the object
Just adding a platform to the scene isn't enough. You also need to add a behavior to the object to make it something the playable character can walk on. Conveniently, GDevelop provides a behavior named Platform behavior that does this for you.
To add Platform behavior to the object:
- Open the Behaviors tab for the "GrassPlatform" object.
- Select Platform behavior.
- Click Apply.
If you preview the game, the player can move across the surface of the platform.
Step 3: Create a different type of platform
GDevelop also provides the Jumpthru platform behavior. This behavior creates a platform that the player can jump onto from beneath it. This adds more variety to the level.
To create a platform with the Jumpthru platform behavior:
- Create a Tiled sprite object named "SmallBridge".
- Use the "bridgeLogs.png" asset as the object's image.
- Open the Behaviors tab.
- Select Platform behavior.
- From the Type dropdown, select Jumpthru platform.
- Click Apply.
Then drag some instances of the object into the scene.