【问题标题】:pygame.mouse.get_pos()..... the x/y co-oridinates not updatingpygame.mouse.get_pos() ..... x/y 坐标不更新
【发布时间】:2015-04-26 04:38:47
【问题描述】:

试图让一个盒子在鼠标经过时改变颜色。我遇到的问题是鼠标坐标没有更新。所以程序不知道鼠标在特定位置上。如何让它保持更新鼠标坐标?

def start_screen():
    game_display.blit(selection_screen,(0,0))
    #buttons

    mouse = pygame.mouse.get_pos()
    print(mouse)
    if 200 + 100 > mouse[0] > 200 and 550 + 50 > mouse[1] > 550:
        pygame.draw.rect(game_display,black,(200,550,100,50))
    else:
        pygame.draw.rect(game_display,white,(200,550,100,50))
    pygame.draw.rect(game_display,white,(700,550,100,50))

    pygame.display.update()

start_screen()

【问题讨论】:

    标签: pygame coordinates python-idle


    【解决方案1】:

    修好了……

    def start_screen():
    
        intro = True
        while intro:
            for event in pygame.event.get():
    
                game_display.blit(selection_screen,(0,0))
                #buttons
    
                mouse = pygame.mouse.get_pos()
    
                if 200 + 100 > mouse[0] > 200 and 550 + 50 > mouse[1] > 550:
                    pygame.draw.rect(game_display,black,(200,550,100,50))
                else:
                    pygame.draw.rect(game_display,white,(200,550,100,50))
    
                pygame.draw.rect(game_display,white,(700,550,100,50))
    
                pygame.display.update()
    
    start_screen()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-05
      • 2022-01-16
      • 1970-01-01
      • 2011-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多