[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Re: Sprite Surface very slow to draw
If found the solution!
The problem is that the documentation needs examples (or maybe I
didn't find good ones):
I was using:
40 self.image.convert_alpha()
I should have done:
40 self.image.convert_alpha(self.image)
(which I don't understand btw)
So the final class which works is:
22 class Contour(pygame.sprite.Sprite):
23 def __init__(self,width,height,speed):
24 pygame.sprite.Sprite.__init__(self) #call Sprite
initializer
25 self.width = width
26 self.height = height
27 self.rect = pygame.Rect(0, 0, width, height)
28 self.image = pygame.Surface( (self.rect.width,
self.rect.height) )
29 self.image.set_colorkey((0,0,0))
30 self.image.fill((0, 0, 0))
31 pygame.draw.rect(self.image, (105,250,230), self.rect, 5)
32 self.fadeout = False
33 if speed<1:
34 raise Exception("Speed must be > 0")
35 self.speed = speed
36 self.alpha = 250
37 self.done = False
38 self.image.set_alpha(self.alpha)
39 self.image = self.image.convert()
40 self.image.convert_alpha(self.image)
By the way, I'm doing:
39 self.image = self.image.convert()
and I don't know whether I should call it or if
40 self.image.convert_alpha(self.image)
does the whole stuff.
Any help would be greatly appreciated!
Olivier Pons