I have a student trying to get their character to change animation when the “g” key it hit. Everything appears to work except that part. The character doesn’t change. It will move left and right when the D and A keys are pressed. Also, his score will not increase as the game goes on as well. Any help would be much appreciated.
Here is a link to the project: Code.org
Can you click the SHARE button on his project and then share that link? When I click on the link you posted, it just takes me to my Unit 3, Lesson 27, Bubble 2 - I can’t see your student’s project. Thanks.
It was hard to see the differences in the sprites! I had to scale it x 2. The other troubleshooting step I took was to try to switch it with a really different sprite so I knew for sure it wasn’t working and it was not. I placed a console.log in the function that is supposed to change the animation and it did run meaning the function is running but the animation isn’t changing. So, when that happens I think about what is also running that is opposing the animation change.
On line 69, I see an else and if the else is triggering, the animation for Jim is always animation_1 so he won’t change to gun. I don’t think you need the else statement on line 69 because the default animation is animation_1. In my mind, if the g key is down, then the animation is gun, else it is animation 1 (so try moving the else statement that changes the animation to gun to the conditional with the g key).