Changing animations when sprite stops moving

A student is trying to make it so the “Hero” sprite shows its “protagonist block” animation once it stops moving right with the right arrow key and show its “protagonist block 2” when it stops moving left. Right now the he continues to “walk” in place.

We can’t figure out how to do it! Any ideas?

Here is a copy of the project so far:

Thanks in advance!

1 Like

@GordonBrune,

Look at lines 62 & 66. The student is “redeclaring” the variable “facingleft” in both of those lines and it has already been declared at the beginning of the program. If they remove the “var” declaration and just leave it as “facingleft” they may be closer to a solution.

Good luck!

Mike

1 Like

Lines 62 & 66 the student redeclared a variable - they wrote var facingLeft = false; instead of facingLeft = false;
same on 93 - but they also misspelled bossHP as BossHP - case matters!

I add a [Remix] here with some minor changes.(https://studio.code.org/projects/gamelab/O_4jUEQa6Is5QO4JvY_kuAvwp5f5ZLiN0zX3zCN3io4)

Keep us updated here, as this looks like a cool project!

1 Like