TypeError: fly.isTouching is not a function

Link to the project or level: https://studio.code.org/projects/gamelab/7YM3cC6WMPSbF97e1t1Ol7LnzTzVWtaCZ0YExnZ_qgU
What I expect to happen: coin moves to random position and score increases if fly touches it
What actually happens: ERROR: Line: 40: TypeError: fly.isTouching is not a function
What I’ve tried (and three students):* renaming all sprites, removing and rebuilding the if statement code, switching browsers, logging out/logging in

fly is a sprite, but on line 32, you try to make it a number (-4). I’m guessing you meant fly.velocityY = -4;

The error comes from fly trying to be both a sprite and an integer.

Best of luck!

Mike

That did need to get corrected.
But the error is still on line 40 despite that change.

Line 28 is also setting fly equal to a number. Something is missing in the first blank. Is it fly.VelocityY …?

Mike

Thank you for the help! The students were able to correct the errors and successfully get the program to work.
I GREATLY appreciate your help!! :smiley:

2 Likes