Step 4: Setting Up a Variable for a Damage Animation

Goal:


One thing that a lot of games do is have some sort of indication/animation when a player takes damage.

Having this indication makes it a lot easier for players to know if they took damage instead of having them just look at a number get closer to zero.

To do this we will need some sort of timer to know how long the animation should be.

Steps:

  1. Stay on the “Sharky” sprite.
  2. From Variables, create a new variable called “SadAnimationTime” and be sure to select “For this sprite only”.
  3. Click the check box to uncheck the SadAnimationTime variable so it won’t appear on the game screen.

Code:


Click to replay