Just a question. Is it only possible to put shapes on top of sprites? Or is there a way to have some shapes on top of a background and then some shapes behind other sprites?
drawSprites redraws all the sprites, so I can’t figure out how to interlayer my sprites and shapes. I can only do sprites first and then shapes.
I don’t want the stars on the castle (the student made it work by the random numbers used), but it would have been easier if layering was possible.
well you can group specific sprites to be drawn at different times and adjust them in the draw order you want
drawSprites(): takes a group or draws all current sprites that have been created
sprite.depth: declares when they should be drawn in the process
drawSprite(): draws a singular sprite rather than updating the full thing
I’m not too sure how you want to layer your sprites so i hope this will solve the issues you’ve been having best of luck!
As @varrience suggests, you can use the singular drawSprite() command to draw a single sprite. It’s not listed in the documentation, but it does work and is useful in a few situations. Make sure to include the name of the sprite inside the parenthesis like this:
This would also have to be done in text mode as there isn’t a block for it.
I haven’t used sprite.depth much, but it could also work. Another key concept, however, is realizing that the order that the sprites are declared at the beginning of your code is also the order they will be drawn, so if you want one to be on top of another, declare it after that one. If you declare the background sprite first, all other sprites will be drawn on top of it.
Hope this helps clarify a little.
I don’t have an issue with the order of the sprites being drawn to each other. I need the background (which is a sprite) then some shapes (which are rects) and then a sprite on top of the rects. I need to be able to place rects in between layers of sprites.
I tried the drawSprite() command, but I got a warning that the drawSprite() hasn’t been declared yet.
Sorry I gave bad information … I will update my post to reflect the correct information.
You need to use drawSprite(castle) WITHOUT quote marks. I said to put it in quote marks and that was wrong information.
You will still get that error message (yellow triangle) but it will work and it won’t exit out of the program.
Here’s a link to my version of your project with the castle being drawn separately. Notice the knight is now behind the castle, so you may have to look at order of sprites so he stays in front.
Sorry for the bad info yesterday.
Thank you so much!