【发布时间】:2019-01-08 11:59:21
【问题描述】:
我目前是 pygame 的新手,想知道如何编写矩形的位置以打印“开始”
到目前为止我的循环是
def game_intro():
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
elif event.type == pygame.MOUSEMOTION:
for button in buttons:
if button[1].collidepoint(event.pos):
button[2] = HOVER_COLOR
else:
button[2] = BLACK
screen.blit(bg, (0, 0))
for text, rect, color in buttons:
pygame.draw.rect(screen, color, rect)
screen.blit(text, rect)
if event.type == pygame.MOUSEBUTTONDOWN:
mx, my = pygame.mouse.get_pos()
我的矩形的定位和大小是
rect1 = pygame.Rect(300,300,205,80)
rect2 = pygame.Rect(300,400,205,80)
rect3 = pygame.Rect(300,500,205,80)
【问题讨论】:
-
buttons是如何定义的?或者这就是你要问的? -
基本上我想做的是
print ('start')当鼠标点击我已经绘制的开始按钮时。开始按钮定义为rect1。
标签: python button menu pygame main