Step 3: Changing Our Costume When Moving

Goal:


We want our shark sprite to look to the left when moving left (Costume 2), and to the right (Costume 1) when looking right.

Once we code this it will look a lot better! But we’re still gonna add a little more to this.

Steps:

  1. Still on the “Sharky” sprite, add the following to our existing code.
  2. From Looks, place a switch costume to block.
  3. From Variables, place a nextCostume block into the switch costume to block.
  4. From Variables place a set to block inside the “if key left arrow pressed” block.
  5. Change it to nextCostume and the number to 2.
  6. From Variables place a set to block inside the “if key right arrow pressed” block.
  7. Change it to nextCostume and the number to 1.

Code:


Click to replay