So I'm trying to make a function inside a "scene" class to have text pop up whenever you press "z" and continue to be blitted for a while.
If I use the pygame.key.get_pressed() it only blitz while Z is pressed. I want it to pop up when Z is pressed and continue to stay on screen for a while.
##This is inside the "scene" class##
def printText(self, surface):
if self.counter < 20:
text = pygame.font.SysFont("Pixelated Regular", 30)
label = text.render("Hello", 0, (0,0,0,))
surface.blit(label, (100,100))
self.counter += 1
##This is inside the main##
if key[pygame.K_z]:
robsHouse.printText(screen)
Just in case I didnt make it clear before: I basically want it the text to be blitted for a couple of frames even after I let go of "z".
Thanks in advance.