Make a Legend of Zelda Styled Health Bar with Hearts! (in 14 events!!)

  • 26 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.capx

hearts-tut.capx

Download now 173.59 KB

Stats

4,852 visits, 18,500 views

Tools

Filling the hearts

Okay, so we have our hearts showing on screen and a functional life variable controlled to be maxLife max. If we change our maxLife variable to 8, we still have 8 hearts. But all of them are empty. So that's our next (and pretty much last) objective here.

Let's start by creating a bunch of stuff On Start of Layout. Here, we will set our life to maxLife and all our hearts to "full" animation (since our life is max). Also, I made it so our text show our life variable with Every tick so it's easier to print screen it.

- Again, I made a bunch of On Start of Layout events for readability. You could very well make only one of those with sub-events, it's the same result.

- Not that I put the lastHeartPositionX all the way above with the other Global Variables. That's just how I like to organize my code.

We should have this as result:

Now let's change the purpose of our TextBox object. Let's say we start the layout, we have life = 5. Let's say we type -2 in the TextBox and hit OK: we want it to show 3. If now we type 1 and hit OK, we want it to show 4.

Here we want to simulate a variable value of damage given to our character, if it's negative, or a healthy item, if it's positive. Also, we want it to be 0 if life turns out negative (since we can't really have a negative health bar, right?) and the maximum value for it is maxLife.

It is pretty simple to make, but if you need help, here is the code for it; you should simply change the On Button Clicked event.

Here it the result:

Play with it a little to see if everything is working (sums and subtractions are right, no negative numbers and no higher than maxLife).

If it's ok, we can move on.

  • 0 Comments

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