Как создать платформер

Index

Tagged

Contributors

Stats

69,516 visits, 72,480 views

Tools

Jump-thru objects

If you place some tiles around, you might notice if you jump in to a tile from underneath you hit your head on it and fall back down. What if you want to make platforms you can jump on to from underneath? This is what the Jump-thru behavior does. Like the Solid behavior you can stand on it with the Platform behavior, but the player can jump on to it from underneath.

Let's make a Jump-thru version of our Tile object. Right-click the Tile object and select Clone object type. This will make a separate object type, Tile2, which can have different behaviors. Delete the Solid behavior and add the Jump-thru behavior.

Use tiles 134 and 135 to make a jump-thru like this:

Run the game. Notice how you can jump on to it from underneath.

Hopefully you now know enough to design a whole level! Here's a zoomed out level design I put together quickly while writing the tutorial. It might help show you some of the possibilities. Notice the use of markers across platforms to keep the snails on their platforms.

Parallax

Try adding a parallax effect to make the background seem further away. Select the Background layer in the layers bar. In the properties bar, set the Parallax property to 50, 50 (which means half speed scrolling). Notice how the background moves slower, giving a distance feel. Using multiple layers all with different parallax rates can create an almost 3D feel to a 2D game.

Conclusion

This tutorial covered a lot. You may want to revise it some time. Here are some of the key points:

- For the player's Platform behavior, always add the movement to an invisible box with no animations. Position the visible, animated player sprite on top of the box. This will prevent animations causing glitches in the platform movement.

- Levels can be built out of tiles.

- The Set mirrored action saves you having to make mirrored copies of all your animations.

- Animations sometimes need some work to get imported, set up with the right speed and looping properties, with the right origin set, and all frames cropped. You may also want to alter the collision masks, although this was not covered.

- Enemies can also be controlled with the Platform behavior. Set Default Controls to No and use the Simulate control action to automatically control movement.

- You can detect if the player is falling on an enemy rather than running in to them by testing if they are both falling and above the enemy on the Y axis when colliding. Otherwise (using 'Else'), they must be running in to the enemy, and they should get hurt.

- Instance variables can store numbers or text unique to each instance of an object. This helps control objects individually, which is useful for "AI".

- Edge markers are a quick and easy way to make enemies go back and forth on a platform.

- Jump-thru are platforms that can be jumped on to from underneath.

- Parallax is an easy and intriguing effect to add to platform games.

Obviously we have not made a full platform game! However, this tutorial has covered the most difficult bits, and the important essentials every platform game creator should know in advance. From here on hopefully you have an idea of how the rest of a platform game is going to come together. It takes time to get familiar with a complex development tool with Construct 2. However, experimenting can be fun, and teach you a lot! So spend a while playing around, breaking things, tweaking things, and see what you can come up with. Happy platforming!

Further reading

You may be interested in the alternative beginner's guide, which is a tutorial to make a top-down shooter. It covers some different points like making a heads-up display, and goes in to instance variables in some more detail too. These are both things that can be applied to platform games, so it would definitely be useful to go through it in addition to this tutorial.

Want to add music and sound effects? See Sounds & Music in the manual.

If you'd like to know more about how events work in Construct 2, see the section on How Events Work in the manual. It's highly recommended so you can get going quickly with your own projects! Then for even more information, don't forget there is complete documentation in the manual.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!