[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] duplicate images



On Thu, Oct 8, 2009 at 11:56 AM, Thiago Petruccelli
<thiagopetruccelli@xxxxxxxxx> wrote:
> Hi!
>
> I am using windows(ugh) in the interface of my game, and then I made a close
> button. My game structure load all images in the startup of the game; but
> when I try to copy then, things don't work as I wanted... when I close a
> window and open another (wich is supposed to have a copy of the close button
> with his own properties), it happens that the close button appears in the
> old place, not in the right place in the opened window. I tried to use de
> copy command from the copy module, but it didn't work. It seems that python
> thinks it's the same object; I want to make a duplicate of it.

The copy module is a brute force copy method that doesn't know any
implementation details of what it tries to copy. It should be used
rarely, if ever (I've never used it).

Pygame images have their own copy method to use if you need to make a copy.

#The original image
close_image = pygame.image.load("close.png").convert()

#Make first close image
window_close1 = close_image.copy()

#Make second close image
window_close2 = close_image.copy()


The rest of your discussion of the problem doesn't make much sense to
me, but this is how you copy images in pygame. Hope it helps. As RB
said, if you just want the same image to be blit in different
locations, a copy is not needed at all, you can blit the same image to
different locations.