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 KB

Stats

3,840 visits, 16,744 views

Tools

Actually changing the health bar

Now the only thing missing is changing the hearts animations with the life variable.

There are many ways to do this. This is how I did it:

1) Below our damage/healthy item simulator (On Button Clicked event) we set all the hearts to the "empty" animation;

2) Then we change the first life hearts to the "full" animation. That means we want to Repeat our next event life times;

2.1) We start by selecting only the hearts playing the "empty" animation;

2.2) Then we simply pick the bottom-most instance and change it's animation to "full".

IMPORTANT AND CRUCIAL STUFF!!!

See, when we created the hearts, we made it so our first heart is in the bottom of the Z-order, and the last heart (the right-most) is in the top. Basically, C2 uses this Z-order thing to determine which object in that particular layer is drawn before the others; we are merely using that too to see which is the left-most heart in the screen (or bottom-most heart in the Z-order) so we can change it's animation.

Here is the code for this section and the final code for our tutorial.

One VERY IMPORTANT DETAIL is the order of conditions in event 6.

First you have to get all "empty" animation hearts and then, from those instances with this animation, you pick the bottom instance. If you swap those two, you are always counting from the very first heart and your hearts will be very messy. Check it for yourself.

This kind of stuff is really important to keep an eye on, because the logic in your head might be right, but if it's not translated correctly, it won't work.

  • 0 Comments

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