3.19-Activity 11

My students and I are having some trouble with Activity 11. When we put the suggested code (If score<10, simple background, else crazy background) in the draw loop with backgrounds that are sprites, the background covers up the bunny and coin. Some more instructions on how to do this one would be helpful.

Yikes!! @bcunningham would you be able to share a link so we can take a look at the code?

thanks!!
Kevin

Hi, I made it into a project. Here’s the link: Function Bunny Collector

I think it is because your backgrounds are pictures/variables. It works if you are using fill colors and shapes and background under the draw tool.

@bcunningham

What Kimberley said is right, but you can also do it with sprites. You just have to do it a little differently. Your sprites show up in the order that you create them, with the ones that you create first in the back, and the ones that you create last in the front. When you call your simpleBackground and crazyBackground functions, you are creating new sprites, so they are going to show up on top of everything else. What you should do instead is create a single background sprite at the top of your code, before you create any other sprites. Then, in your function, only set the background sprite’s animation to the image you want, rather than making an entirely new sprite.

Elizabeth

2 Likes

Good morning.

My students and I are having the same problem. We have it set up exactly like the recommendation, the new background sprites being drawn in the IF/ELSE statement just before the drawSprites, but it was still drawing the backgrounds on top of the bunny and coin.

I think I understand what you are saying. I will have the student setAnimation to the crazy background image when coins >10 or the simple background image when coins <= 10.

hi @sharon.elzey!

Let us know what happens!

thanksss!!
kevin

Hi @sharon.elzey,
Just checking in. Did you and your students get everything figured out ok?

Sorry it took so long to reply. Yes, we tried what was suggested and it worked. The student created a single sprite for the background with two separate images. Then in the IF/ELSE statement in the function he set the animation image for the background he wanted to occur. Thanks!! :slight_smile:

2 Likes