Life counter

1

Stats

5,119 visits, 7,383 views

Tools

Translations

This tutorial hasn't been translated.

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.

Published on 12 Nov, 2013. Last updated 19 Feb, 2019

Life Counter

Hey there, i decided to make another simple tutorial but now for beginners and will explain how to make health counter.

Starting

Ok let's do it fast just create new empty project. Double click on your white screen and chose "Tiled background" now one window opened you can create your own background in photoshop or in construct too but for this time i added my work here :)

Ok now we have background but change position of it to 0, 0 and resize it fit to your layout.

Sprites

Let's make few sprites first make your player sprite and sprite for your monster or anything what will decrease your health. You will be able to download my sprites below.

Now place it on your layout don't forget place it inside. Sprites are done let's jump in to behaviours.

Behaviours

Behaviours are interesting and why? Because behaviours making all functions for your sprite or objects. It's simple just chose your player sprite and left click on it and add behaviours. We have to add 8-Directions behaviour for player sprite so lets do it. For another sprites you dont need to add any behaviours at this time.

Layers

Layers are something like positions on your screen you can have top layers or bottom layers. Layers placed on top of layout are primary so you will be able to see it at any time but bottom layers like background can be overlapped with another like HUD or main. Stop with explaining and let's start with work.

Just on right side chose layers menu and add 2 more layers. Change their names to background ( bg if you want ), main and HUD. Be sure your background layer is at bottom and HUD and top so main will be at middle. Now click on your background sprite and on left side panel at Common chose layer to layer background and lock it on your right side other textures move to main layer.

Text

You have to add few more things to your main screen and its text box of course. So double click on your screen and chose text, do it 3 times. Change their names to HP, TotalHP, HPCOUNT (i'm using this names you can chose your own of course ) so you have 3 text boxes and for this part its done.

Event Sheet

Right click on your event sheet screen and add Global variable and name it "CurrentHP" now let's make substract process and set it to max HP as you'd like for me its 10 so number will be 10. Add your first condition Player > On collision with another object > Object is substractHP ( small red ball with my textures ). Now action for this condition is "System > Substract from CurrentHP 1" So each time when you hit red ball you will lose one health it's called "Substract" and now System > Every tick and action Text "HP" Set text HP. So every 10ns ( nano seconds ) will change your text to your current HP don't worry about lags this will never be able to make lags. Now let's place your text box. First on left side place text box called "HP" and right from this "HP" box place HPCOUNT box and in bottom of HPCOUNT text place text TotalHP and now let's continue to event sheet. Add another condition System > On start of layout and action Text box "HP" set text to "HP" and text box TotalHP set to "10" right now only start debugging and here you are :)) Thanks for reading my short tutorial i hope it was useful and if you want to support me just check my profile you can see there more tutorials:

Link with Ads

Normal Link

  • 0 Comments

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