Goal:
Let’s create a loop that will help us run our health damage indicator for two seconds in the game.
Steps:
- Still on the “Sharky” sprite, add the following code.
- From Events, grab a when I receive block and change it to “HealthLost!”
- From Variables, place a set to block and change it to sadAnimationTime and set the number to 2.
- From Control, place a repeat until block.
- From Operators, place a < block inside the repeat until block.
- From Variables, place a round sadAnimationTime block to the left of the < block and set the right side to 1.
- From Control, place a wait 1 seconds block.
- From Variables, place a change by block and change it to sadAnimationTime and set the number to -1.