Functions and changing backgrounds

My student is tring to have her backgound go from plain white to an animation background. Also, she can’t get her score to show.

@langilla1 ,

Looks like it does have an animation background. If you still have questions about that, let us know.

As a result, though, the score is hidden behind the animation background. So, you will want to make sure the text block is the last thing in the draw loop, so it will draw the Sprites before it adds the text.

If this doesn’t answer your question, please let us know!



She also wants the background to change from white to the animation backgound after she reaches 10 scores.


I see how they’ve tried to make that happen so I have a few suggestions.

Right now, they are calling rainbow at the beginning of the code before the draw loop, so this is covering up the other sprites.

So, I think the first step is to not call the rainbow function at the beginning of the code. The code that decides when the rainbow should show up IS working.

There is still another problem, though, because when the score reaches 10, the rainbow shows up and covers up the bunny, the coin and the score again.

One issue is that the rainbow sprite is created inside the function. Creating sprites in a function that itself is in the draw function will create that sprite over and over again and this will cause problems. The sprite should be created and the animation assigned at the top of the code before the draw block. Then they could find a block that makes the sprite invisible to start with. Then, when the score is greater than 9, they could make the sprite visible again?

If it is still covering the other objects, the drawSprites block draws the sprites in the order they were created, so make sure the rainbow is the first one created at the top of the code.

This is hopefully something to get them down the right path, but may not solve every issue. If they get further, but are still having issue, please check back in!

Good luck!