Reputation: 86
I am relatively new to pygame (and also terrible) so naturally I am having many problems. One of which is using images. How would I go about "layering" images in PyGame? I have searched and come to the conclusion that surfaces may help, but I can't seem to figure out how to use them. Any help would be greatly appreciated! I'm simply trying to blit an image above my sprites, but the sprites always end up on the top of the image.
I have attempted to fill the screen before blitting the image, but it didn't work.
display.fill((0,0,255))
display.blit(pygame.transform.scale(teacher_image, (500,500)),(150,200))
Any suggestions?
Upvotes: 1
Views: 1207
Reputation: 14906
The ordering of images, known as "z-order", is simply controlled by the order they are drawn to the screen.
Think of the first image as being draw with a z-order of 0, whereas later images are draw with a higher z-order, so they lay on top of the previous images.
It's possible to change the various image's z-order by changing the ordering of the calls to blit()
.
Upvotes: 1