Pausing Frame Update While Jumping

In the video on moving the hazard, I completed the challenge of pausing frame animation updates by placing the frame++ call inside of the if !isInAir check. It seems to work just as well as placing the whole block inside the check.

I am wondering if there is any performance benefit one way over the other, though. I would think its a best practice to only affect the animation itself, which is why i only encapsulated the call to the next frame instead of the whole animation block.

If anyone has any insight on this i would love to discuss it.

I’m no expert, but I think your code is cleaner, but given where we are with this video, it might impact something that is added later. I completed the task by using an OR in the IF check for frame position but that would reset the image back to 0 whenever you jump which doesn’t look as clean as a jump from current running position. But good to know if you have a jump animation you might want to use in a future game.