Building a platform game - a beginner's guide

7
  • 265 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.capx

platform-tutorial-i.capx

Download now 608.15 KB

Contributors

Stats

48,169 visits, 196,300 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Look, too, at the animations of the PlayerImages that we're going to use. Click on the PlayerImages object in the Project Bar, and then on 'Animations - Edit' on the left. What you'll see is something like this (click on 'Running' in the 'Animations' window to see the five frames of that animation) :

Now run the layout to see how it looks in your browser. Did you try pressing the keys? And were you disappointed? That's because we've not yet given the objects any behavior and added events to make use of that behavior. We'll do that now.

Click on the 'Flooring' object in the Project Bar, then click on 'Edit behaviors - Add / edit' in the Properties Bar. Give it 'Solid' behavior (under 'Attributes').

Do the same for the 'Wall' object.

Click on the 'Player' object in the Project Bar, and give it 'Platform' behavior (under 'Movements').

Remember that we need to pin the PlayerImages object to the Player object. So click on the 'PlayerImages' object in the Project Bar, and give it the 'Pin' behavior (under 'General').

Run the layout again. Still no movement? Well, yes, there is, actually. You just can't see it, because the Player object is ... invisible, remember? If you temporarily change its initial visibility to 'Visible', you'll see that the Player does indeed move as you'd expect a Platform object to move. It just doesn't look very interesting - even when visible. Let's dress it up:

Click on the 'Event Sheet 1' tab. (To describe the events to add, I'll use Ashley's notation from his 'Beginner's Guide')

Condition: System -> On start of layout

Action: PlayerImages ->Pin: Pin to object -> for Object, choose the Player object

Action: PlayerImages -> Set animation -> for Animation, type in "Standing" (leave 'From' on 'beginning')

Run the layout again. Now you can see Tim slide along the floor when we press the arrow keys, stop when he bumps into the wall, and, best of all, jump when we hit the up arrow key. See if you can get him onto the highest floor - but careful, if he falls, he may drop out of the game altogether.

  • 1 Comments

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