Construct 2 for beginners
Written by Kenney on 04/09/2016
Construct 2 is a game development tool produced by Scirra. It allows for easy game creation using visual programming, games made with Construct 2 are HTML5 compatible and work on pretty much every platform. The tool is available for free, but a professional license grants a few more options.
In this guide you'll learn how to create a simple platformer game where the user can move around, jump and collect items.
On the left side of the interface you'll find the properties of the currently selected object. If nothing is selected you'll see the properties of the current layout or project. In the center you'll find the stage where the game stage is build. On the right side is an overview of all content your project currently contains.
Layout and event sheets
In the center section you'll notice two tabs. The first (opened) tab is the layout. On the layout you'll place objects and tiles to create the world in your game. The other tab (event sheet) is considered the engine of the game. Here you'll be combining events and actions to tell that game what to do.
Creating a sprite
Double click an empty area on the layout to open the dialog to create new objects. Among the objects you'll find the sprite, a sprite is an object which can be moved, animated and interacted with. Perfect for characters, items, buttons and more. Once you've selected the sprite you'll get a crosshair cursor, click on the stage to place the sprite.
After you've placed the sprite a new dialog will open which features various tools to draw the sprite. You can also open an existing image by clicking the folder icon. Draw or select an image which represents the character of your game. Close the dialog.
While most development tools would require you to program the movement of the player Construct 2 has a few built-in behaviors which do a lot of the work for you. One of these behaviors is perfect for a platformer character. Select the character and click on the blue behaviors text in the left panel (properties).
A new dialog will open up and show you a list of currently active behaviors for this sprite (none). Click on the symbol to add a new behavior. In the newly created dialog select the "Platform" behavior. Once it's part of the behavior list, close the dialog.
Test the game by clicking the " Run layout" button on top, you'll find out that the character falls off the screen.
Building the world
We'll need a platform for our character to stand on. Click an empty area on the layout and create a new sprite, select or draw something that the player can stand on. Once done, close the dialogs and add the "Solid" behavior to the tile. Place the tile under the player (drag 'n drop) and hit " Run layout".
You'll see that the character can now safely stand, you can move and jump around. Hold CTRL while dragging the tile to easily create duplicates.
Follow the player
As you might've noticed the screen is static and doesn't follow the player, even if you've built a large game world. Adding a camera that follows the player is extremely easy thanks to a pre-made behavior. Select the player object and add the "Scroll To" behavior. Test your game and you'll see that a virtual camera now follows the player anywhere.
The game is kind of dull and it would be nice if the player had a goal to achieve. Create a new sprite and draw or load an image that looks like a pick-up (coins, jewels, gems etc.). This time instead of a behavior we'll do some custom coding.
Once you've created the sprite switch to the "event sheet" tab. Click on the "Add event" text to add a new event. In the new dialog select the player sprite and then "On collision with another object", in the next dialog select the sprite for the pick-up. Now we've created an event; when the player touches the pick-up...
Click on 'Add action' next to the newly created event. Select the pick-up sprite and they "Destroy". Now we've created the first action; when the player touches the pick-up the pick-up sprite will be destroyed. Easily said;
Player touches Gem Destroy Gem
Hit " Run layout" and see if you can collect the gems.
What to add next?
Check out our other guide which has a whole lot of ideas which tiles and objects can be added next!
Reading time: about 3 minutes
Beginner guide to game developmentby Kenney
Our Ludum Dare experienceby BeefEX
Manipulating pre-made game assetsby Kenney