Solution for stopping animations on jumping for Scarfy

Hello,

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;
            frame++;
            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

Privacy & Terms