【发布时间】:2021-03-28 14:49:27
【问题描述】:
我有一个代码,当玩家击中一个矩形时会弹出一个语音气泡。但现在它只是在给讲话泡泡发垃圾邮件。这不好,因为我有随机出现的文本,所以它只是通过它非常快
这是对话泡泡的代码
def draw_speech_bubble(screen, text, text_color, bg_color, pos, size):
font = pygame.font.SysFont(None, size)
text_surface = font.render(text, True, text_color)
text_rect = text_surface.get_rect(midbottom=pos)
#Background Object
bg_rect = text_rect.copy()
bg_rect.inflate_ip(10,10)
#Border
border_rect = bg_rect.copy()
border_rect.inflate_ip(4,4)
pygame.draw.rect(screen, text_color, border_rect)
pygame.draw.rect(screen, bg_color, bg_rect)
screen.blit(text_surface, text_rect)
这是我的碰撞代码
if(player.player_rect.colliderect(BarCounter)):
draw_speech_bubble(screen, str(RandomText()), (255, 255, 255), (0, 0,0),SpeechBubbleAnchor.midtop,25)
我想要某种冷却时间,这样它就不会向语音气泡发送垃圾邮件。我尝试使用刻度进行计算,但我无法做到这一点
【问题讨论】:
标签: python python-3.x pygame