Platform-Style Video Games with Construct

Creating Spikes that Reduce Health

Your browser needs to be JavaScript capable to view this video

Try reloading this page, or reviewing your browser settings

This video shows how to create a stationary obstacle that damages the character and may cause the player to lose the game.


  • Construct 2
  • Sprites
  • Obstacles

About this video

Lee Stemkoski
First online
15 February 2019
Online ISBN
Copyright information
© Lee Stemkoski 2019

Video Transcript

Lee Stemkoski: Finally, we’ll add an object to the environment which can cause harm to the player. We’re going to add some spikes which caused the Koala to lose health if it collides with them.

To begin, in the layout, let’s right click and Insert a new object. Click once on Sprite and for the Name when inserted, let’s name this Spikes. Click on Insert. Click on the layout to place the starting location. This is just a single image, so we’ll click on the folder icon. I’ll choose the file called spikes.png. And click on Open. And I click on this zoom in and I need to adjust the collision polygon. If I click on this icon, the lower left, sometimes Construct does not guess the shape very well, so I’m just going to click on these red vertices and rearrange them, so it surrounds these. After adjusting that, I can click on this x to close. I will position these spikes down here.

And now, let’s go to the Event sheet. Let’s add an event. This event will say whenever the Koala collides with the spikes, it’s going to get damaged. So Koala, Next, On collision with another object. That object is the spikes. Then we’ll add an action. That action will be to reduce the amount of health. So let’s do a System condition or System action rather. Choose system. Since we’re adjusting the value of health under the category Global and local variables, let’s choose the action, Subtract from. And we’ll change the variable we’re subtracting from. Change that to Health. Maybe we’ll subtract the value 1. So now when the Koala collides with these spikes, it will lose one health point. Now that we’ve added this event, it’s time to save and test it out. Click on the save button, navigate back to the layout and let’s give this a preview. All right. My health is now 3. If I walk over to the spikes, my health is now 2.

Now, one thing, we might like is some visual feedback for this event. Often in games, there’s some type of animation that appears to indicate your character has taken damage. In fact, if you’re not paying attention, you might walk through the spikes and you might not be looking at your Health and realize that something has happened. We could add a sound effect and we will do that later. But for now, I would also like to add some flashing to the Koala as well to indicate that damage has been taken.

To do this, let’s close the Preview window, and in the layout, let’s click on the Koala and in the Properties panel or it says Add/edit Behaviors. Let’s click on that underlying behaviors. We’ll add a new one to this list. I’d like to add the behavior of Flash. Now that we have three behaviors in the list, let’s close that window. Let’s go to the Event sheet and let’s add an action. That action is going to be a Koala action. And now that we’ve added the Flash behavior, we have a new category of actions called Flash. And this is how long we want to flash for, how many seconds the character is visible and then invisible. The only thing we want to change is the duration. Maybe we’ll flash for two seconds. So I’ll change that third number to a 2 and click on Done.

Now we’ll save and try that out again. Walking over to the spikes. Now when we hit them, we flash. Maybe we can tell that something’s wrong. Excellent. Our world is becoming full of interesting things. And in the videos that follow, we’ll be adding some more features to this level.