Step 8: Changing Our Shark’s Costume

Goal:


After looking at the shark costumes, you should notice that the damaged costume is 4 indexes away from the undamaged one (for example, the moving left costume is 2 and the moving left damaged costume is 6).

With this in mind let’s add the following code which will use the shark’s current costume number to decide which sprite to use.

Steps:

  1. From Looks, we need two switch costume to blocks that we will place before and after the repeat until block.
  2. From Operators, place a + block into the first switch costume to block. Then place a block into the second switch costume to block.
  3. From Looks, place a costume number block into the left side of the + block and a blocks.
  4. Set the right side of the + and block to 4.

Code: