0

boltAnim.blit(winsurface, (pos[0]-50,pos[1]-100)??)

I am wondering how I can blit an image to front to the other images, I understand whatever I blit last will be shown last, but how can I set the blit parameters to send the image forwards or backward on the surface?

pythonhunter
  • 1,047
  • 3
  • 10
  • 23
  • 1
    There is no Z order parameter in 2D. Just blit them in the order you want back to front. – cmd Oct 06 '15 at 19:18

2 Answers2

1

Simply change the order in which the images are blited on the surface/screen.

Example:

screen.blit("dot1")
screen.blit("dot2")

This will show dot2 on top of dot1.

screen.blit("dot2")
screen.blit("dot1")

This will show dot1 on top of dot2.

J.Clarke
  • 392
  • 2
  • 15
0

If you want a way to change the order of items blitted on the fly you can populate a list with images and iterate over the list to draw them all. When you want to move something forward or back, change its order in the list

e.g:

items_to_be_drawn = [background,image1,image2]
for item in items_to_be_drawn:
    screen.blit(item,(0,0))

and to change the order you can use something like this: How can I reorder a list in python?

items at the start of list will be at the back and every subsequent item will be on top of the last

Community
  • 1
  • 1
DCA-
  • 1,262
  • 2
  • 18
  • 33