Change background image(animation) when score reaches a number


A student wants the background image(animation) to change to another background image(animation) once the score reaches a certain amount. I am wondering, if they should include an IF statement inside showScore in order for it to work. Again making sure the order is:




The above link isn’t set for sharing - but generally you want to draw the background sprite first and then change the costume based on the if statement. Try it out and then come back and let us know if it worked OR if you have further questions.



I published this, so it should be shareable.



Sorry, still getting an error (see attached screenshot). This might be part of a bigger issue - might want to submit a bug report.



Your student is really close. She’s using the if statement correctly for the most part.

The problem is that she’s using two sprites for the background, rather than just changing the animation of one sprite. Right now, she creates both of the sprites, and the one that she creates second shows up, because it’s the one that’s on “top” of the other when all the sprites are drawn.

Then, in her background function, she resets the animations of those two sprites. This isn’t doing anything, though, because those two sprites already have the respective animations that she’s setting them to.

What she should do instead is create only one sprite, and to set it to the image that she initially wants for the background. Then, in the Background function, use the same if statement, but in both cases set the animation of that original sprite. This way the sprite just changes what it looks like, rather than having two completely separate sprites.



Also, it looks like sharing permissions might not be turned on for your student. For students under 13, the default is not to allow them to share Game Lab projects. Teachers can edit this setting in the teacher dashboard.



Thanks to Elizabeth_admin for your help. We made the changes you suggested, 1 var background sprite, changes to a 2nd one not listed as a var.