Code not working on card

Hello, I see the text will appear if the draw sprite is above the text blocks. Is this always the case with the background is a static sprite?
I also cannot get the crab to move to the right.

Thanks

If you’re using a sprite for the background then yes, you do need to add any text on the screen after callding drawSprites()

The bug that you’re seeing with the crab not moving is an interesting one - it’s not moving because you are recreating the crab at 200, 200 every time the draw loop is run. So each run of the draw loop, you create a new field sprite and a new crab sprite at 200, 200. Even after you update the crab’s position to 201, 200, you’ll never see it again because the next iteration of the draw loop with create a new one on top.

You want to create sprites before the draw loop so that they only get created once, and then you can modify the sprite properties - just take lines 2-7 and move them above the draw loop.

3 Likes

This is a gotcha that some of my students encountered as well. They did not get the concept of creating a sprite outside the draw loop until they experienced similar outcome. I created a sample and had them troubleshoot it as a group activity to help them understand the concept of creating the sprites once and making them move/hide/show within the draw loop.

2 Likes

Thank you for your help!