Building a platform game - a beginner's guide

Index

Tagged

Attached Files

The following files have been attached to this tutorial:

.capx

platform-tutorial-i.capx

Download now 608 KB

Contributors

Stats

13,752 visits, 14,075 views

Tools

Tim will soon wear out his shiny shoes if he keeps sliding along the floor, so we need to get him to run. Add another event:

Condition: Player -> Platform: On moved

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

Run the layout again, and note three unrealistic effects:

- He runs backwards instead of turning around and running forwards.

- He keeps running even after he's bumped into the wall.

- He keeps running on the spot when you take your fingers off the arrow keys.

To deal with the first problem, we obviously need another animation showing Tim running the other way. But I've not made one, and the good news is that you don't need to, either - thanks to the smarts of Construct 2, there's a very easy way to get him to turn round and run left. Add another event:

Condition: Keyboard -> Key is down -> press the left arrow key

Action: PlayerImages -> Set mirrored (under 'Animations') (leave 'Mirrored' as is)

Run the layout again. Ah! Once Tim starts running left, he keeps doing it, even when you make him go right. Add another event:

Condition: Keyboard -> Key is down -> press the right arrow key

Action: PlayerImages -> Set mirrored -> and this time select 'Not mirrored'

Now Tim runs in a much more realistic way - except that he still keeps running even after he's bumped into the wall.Two more events are needed:

Condition: Player -> Platform: Is by wall -> Side: left

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

Condition: Player -> Platform: Is by wall -> Side: right

Action: PlayerImages -> Set animation -> "Standing"

Now Tim strikes a more realistic pose when he bumps into a wall. But that creates an unwelcome side-effect. Have you spotted it? Yes, he stays in that standing pose when you move him away from the wall. It's not enough just to check whether he's up against a wall before we make him stand - we need to check whether he's moving or not. So we need to add a second condition:

Right-click in the 'Platform has wall to left' condition and select 'Add another condition':

Condition: Player -> Platform: Is moving

But that's not what we want - we want the opposite. Not a problem - we simply invert the condition:

Do the same for the 'Platform has wall to right' condition. Fixed!

Now to deal with the problem that Tim still runs on the spot when you take you fingers off the keys. Perhaps by this stage you can work out for yourself what needs to be done:

Condition: Player -> Platform: On stopped

Action: PlayerImages -> Set animation -> "Standing"

At last, Tim moves (and stops moving) in a more realistic manner.

  • 0 Comments

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