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

[pygame] font alpha



Hi all,

Apologies for the seemingly newb help request but I can't seem to figure out how to vary the alpha value of rendered font surfaces. Here are my attempts thusfar:

import pygame
pygame.init()
screen = pygame.display.set_mode((640,480), pygame.SRCALPHA)
screen.fill((0,0,0))

myFont = pygame.font.Font(None, 30)
nonTransparent = myFont.render("This text should be fully opaque", 1, (255,255,255))
screen.blit(nonTransparent, (0,0))
semiTransparent = myFont.render("This text should be somewhat transparent", 1, (255,255,255))
semiTransparent.set_alpha(100)
screen.blit(semiTransparent, (0,100))

pygame.display.flip()
#When I flip, both messages are the same color, indicating that the transparency on the second failed


--
Mike Lawrence
Graduate Student, Department of Psychology, Dalhousie University

Website: http://memetic.ca

Public calendar: http://icalx.com/public/informavore/Public

"The road to wisdom? Well, it's plain and simple to express:
Err and err and err again, but less and less and less."
	- Piet Hein