pythonhunter
pythonhunter

Reputation: 1117

How to I blit an Image to the front of the other images?

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?

Upvotes: 0

Views: 1621

Answers (2)

DCA-
DCA-

Reputation: 1292

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

Upvotes: 0

J.Clarke
J.Clarke

Reputation: 370

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.

Upvotes: 1

Related Questions