所以我有这个功能可以将文本闪烁到屏幕上:
def text_speech(font : str ,size : int,text : str,color,x,y, bold : bool):
SCREEN = width, height = 900, 600
font = pygame.font.Font(font,size)
font.set_bold(bold)
text = font.render(text, True, color)
textRect = text.get_rect()
textRect.center = (x,y)
screen.blit(text,textRect)
Run Code Online (Sandbox Code Playgroud)
如果我有
screen.fill((0,0,0))
text_speech('arialnarrow.ttf', 30, 'Hello', (255,255,255),
width/2, height/2, False)
Run Code Online (Sandbox Code Playgroud)
它在带有白色文本的黑色屏幕上打印“你好”。如果玩家将鼠标悬停在此文本上,我如何使文本气泡看起来像这样:
我只想要一个绿色背景的文本,上面写着“点击确认”。任何人都知道如何做到这一点。我很抱歉,我对 Pygame 有点陌生。