擅长:python、mysql、java
<p><strong>在回答过快后编辑了</strong></p>
<p>移动你的循环:</p>
<pre><code>while running:
rect = pygame.Rect(10, 20, 30, 30)
pygame.draw.rect(screen, (255,0,0), rect)
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
mouse_pressed = True
if event.type == pygame.QUIT:
running = False
while mouse_pressed:
# do your stuff
mouse_pressed = False
</code></pre>
<p>在您的版本中,整个循环永远不会启动,因为<code>mouse_pressed</code>被初始化为False。在</p>