• Advertisement
Sign in to follow this  

Rect is not transparent

This topic is 1902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I changed the backgroud for MyPong from black to red just to show you that Rectangle of the ball is not transparent.
I looked at web, there is transparency, but it affects all picture not just corners. For that I suppose I will need Sprite class from Pygame, but I wanted to check if there is any solution for this, before moving to sprites.

Z
Ups I didnt post any code so:
[source lang="python"]
def draw_circle(radius, color):
size = radius*2
pict = pygame.Surface((size, size))
pygame.draw.circle(pict, color, (radius, radius), radius)
return pict, pict.get_rect()
ball, ball_rect = draw_circle(10, [0, 100, 50])
[/source] Edited by Zed McJack

Share this post


Link to post
Share on other sites
Advertisement
Ok, I found solution.
Its not Rect, the Surface is the solution as Rect is drawn onto a Surface and you can set colorkey for transparency so I added.
[source='lang="python"']ball.pict.set_colorkey((0,0,0))[/source]

and it worked

Z.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement