I had a look online at quite a few tutorials but I can't seem to get a translucent red circle to be drawn on a surface.
I want this method to be used to highlight a sprite with a translucent red circle:
def highlight(self):
s = pygame.Surface((self.rect[2]*2,self.rect[3]*2)) #create a surface to draw circle on twice as big as the sprite rectangle)
s.fill((0,0,0)) #fills the surface with black
pygame.draw.circle(s, (255,0,0), self.rect.center, self.rect[3], 0) # draws red circle on the surface
s.set_colorkey((0,0,0)) # makes the black surface background transparent
s.set_alpha(50) # makes the whole surface translucent (i.e. the red circle remaining)
variables.screen.blit(s, (self.rect[0]-self.rect[2]/2,self.rect[1]-self.rect[3]/2)) #blit's the red circle centered on my sprite.
I really don't know what I do wrong... I can get the red circle alright by just using:
def highlight(self):
pygame.draw.circle(DISPLAYSURF, (255,0,0), self.rect.center, self.rect[3], 0) # with display surf as my background for the whole game
But I can't get it translucent. I'm also reluctant to use gfxdraw as it says it might not be supported in future Pygame versions.
Thank you for your help.