Solution for stopping animations on jumping for Scarfy


I solved the challenge to stop Scarfy animating when in midair, however I didn’t nest my code into another If statement, I only added a logical AND operator plus a negation operator for ‘isInAir’. Is this good practice or is the idea for the challenge to show we can solve what we’re tasked as there could be multiple solutions?

        if(runningTime >= updateTime && !isInAir)
            runningTime = 0.0;
            // update animation frame
            scarfyRec.x = frame * scarfyRec.width;
            if(frame > 5)
                frame = 0;

To be fair, any coding problem can have multiple solutions!

There’s nothing wrong with your solution here, well done!

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms