Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I may have not been clear in my original question, but I think I figured it out on my own. What I was looking for turns out to be Surface's set_alpha() method, so all I had to do was make sure that translucent images were on their own surface.</p> <p>Here's an example with my stripped down code:</p> <pre><code>import pygame, os.path from pygame.locals import * class TranslucentSprite(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self, TranslucentSprite.container) self.image = pygame.image.load(os.path.join('data', 'image.bmp')) self.image = self.image.convert() self.image.set_colorkey(-1, RLEACCEL) self.rect = self.image.get_rect() self.rect.center = (320,240) def main(): pygame.init() screen = pygame.display.set_mode((640,480)) background = pygame.Surface(screen.get_size()) background = background.convert() background.fill((250,250,250)) clock = pygame.time.Clock() transgroups = pygame.sprite.Group() TranslucentSprite.container = transgroups """Here's the Translucency Code""" transsurface = pygame.display.set_mode(screen.get_size()) transsurface = transsurface.convert(screen) transsurface.fill((255,0,255)) transsurface.set_colorkey((255,0,255)) transsurface.set_alpha(50) TranslucentSprite() while 1: clock.tick(60) for event in pygame.event.get(): if event.type == QUIT: return elif event.type == KEYDOWN and event.key == K_ESCAPE: return transgroups.draw(transsurface) screen.blit(background,(0,0)) screen.blit(transsurface,(0,0)) pygame.display.flip() if __name__ == '__main__' : main() </code></pre> <p>Is this the best technique? It seems to be the most simple and straightforward.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload