Python 在pygame中更改悬停时矩形的边框
我有一个矩形:Python 在pygame中更改悬停时矩形的边框,python,pygame,Python,Pygame,我有一个矩形: PlayButton = pygame.draw.rect(screen, (0, 0, 0), pygame.Rect(324, 380, 354, 35)) 我想让矩形的边框在用户悬停在矩形上时变为红色 # Checks if the rectangle is hovered over if PlayButton.collidepoint(pygame.mouse.get_pos()): print ('mouse is over newGameB
PlayButton = pygame.draw.rect(screen, (0, 0, 0), pygame.Rect(324, 380, 354, 35))
我想让矩形的边框在用户悬停在矩形上时变为红色
# Checks if the rectangle is hovered over
if PlayButton.collidepoint(pygame.mouse.get_pos()):
print ('mouse is over newGameButton')
谢谢当鼠标悬停时设置一个状态变量: hover=PlayButton.collidepoint(pygame.mouse.get_pos()) 在设置了
宽度
参数的位置绘制一个附加图形:
e、 g.红色边框,厚度为3
如果悬停:
pygame.draw.rect(屏幕,(255,0,0),pygame.rect(32438035435),3)