📜  pygame 中的鼠标底部 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:05.106000             🧑  作者: Mango

代码示例1
while...: #your loop
  
    button = pygame.Rect(cordX, cordY, width, height) #your bytton
    pygame.draw.rect(win, (0, 0, 0), button) #show button
    
     mx, my = pygame.mouse.get_pos() #mouse pos

     if button.collidepoint((mx, my)): #cheak if mouse on button  
          if pygame.mouse.get_pressed()[0]: #cheak if mouse is preesed
           # writh here what you want to happend
     pygame.display.update()