U3.14 getting text in front of sprite


#1

My student has icicles as part of her background, but it is a sprite. How can she get words to appear IN FRONT of the icicles, or any sprite? We have played around with order but it doesn’t seem to matter. Thank you!


#2

hi @mmgust!

Would you be able to share a link to the project?

thanks!
Kevin


#3

If they all are sprites, its the order of creation that matters.
The first one that gets created is always on the bottom.

var sprite2 = createSprite(200, 200);
sprite2.setAnimation("cow_1");

var sprite = createSprite(200, 200);
sprite.setAnimation("brown_cat_1");

Above, sprite will be in front of sprite2 because sprite was created after sprite2

Or
You can change this later by using the depth property of the sprite.
The higher the value of the sprite’s depth, the more in front it is.

Here is a little demo to show it.


#4

Another thing to note is that sprites are all drawn when the drawSprites command is used, so in order for plain text to appear on top of sprites, you will need to use the text command AFTER you use the drawSprites command.

Elizabeth