Barre de vie style "Legend of Zelda" avec des coeurs. (14 événements)

1

Index

Fichiers attachés

Les fichiers suivants ont été attachés à ce tutoriel:

Statistiques

6,934 visites, 12,106 vues

Outils

Partager

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 14 Dec, 2015. Last updated 25 Feb, 2019

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

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