• pygame.mouse--鼠标


    pygame.mouse函数

    pygame.mouse.get_pressed()  ——  获取鼠标按键的情况(是否被按下)

    import pygame
    
    pygame.init()
    screen = pygame.display.set_mode((196, 100))
    pygame.display.set_caption("pygame.mouse函数")
    
    while True:
        event=pygame.event.wait()
        if event.type == pygame.QUIT:
            exit()
        b=pygame.mouse.get_pressed()   #获取鼠标按键的情况(是否被按下)
        #返回一个由布尔值组成的列表,代表所有鼠标按键被按下的情况。True意味着在调用此方法时该鼠标按键正被按下
        #(1, 0, 1)  表示左键和右键被按下(左键、中键、右键)
        #这条语句没有体现滚轮的滚动
      #必须先调用pygame.event.wait等语句后才能工作
    print(b) pygame.display.update()

    pygame.mouse.get_pos()  ——  获取鼠标光标的位置

    import pygame
    
    pygame.init()
    screen = pygame.display.set_mode((196, 100))
    pygame.display.set_caption("pygame.mouse函数")
    
    while True:
        event=pygame.event.wait()
        if event.type == pygame.QUIT:
            exit()
        b=pygame.mouse.get_pos()   #获取鼠标光标的位置
        #返回鼠标光标的坐标 (x, y)。这个坐标以窗口左上角为基准点
        #必须先调用pygame.event.wait等语句后才能准确获取
    
        print(b)
    
        pygame.display.update()

    pygame.mouse.get_rel()  ——  获取鼠标与前一位置的偏移量

    pygame.mouse.set_pos()  ——  设置鼠标光标的位置

    import pygame
    
    pygame.init()
    screen = pygame.display.set_mode((196, 100))
    pygame.display.set_caption("pygame.mouse函数")
    
    while True:
        event=pygame.event.wait()
        if event.type == pygame.QUIT:
            exit()
        pygame.mouse.set_pos(50,10)   #设置鼠标光标的位置
        #如果鼠标光标是可视的,则光标将会跳到新的坐标上。移动鼠标将会产生一个新的 pygame.MOUSEMOTION 事件
    
        print('a')
    
        pygame.display.update()

    pygame.mouse.set_visible()  ——  隐藏或显示鼠标光标

    b=pygame.mouse.set_visible(False)  #设置鼠标是否可见
    #True 可见,False 不可见
    #返回值:返回在设置之前的状态

    pygame.mouse.get_focused()  ——  检查程序界面是否获得鼠标焦点

    b=pygame.mouse.get_focused()  #pygame窗口是否在接收鼠标事件
        #当 pygame 正在接受鼠标输入事件(或者用专业术语说,鼠标正在处于“active”或“focus”状态)返回值为 True

    pygame.mouse.set_cursor()  ——  设置鼠标光标在程序内的显示图像

    pygame.mouse.get_cursor()  ——  获取鼠标光标在程序内的显示图像

    b=pygame.mouse.get_cursor()  #获取鼠标光标在程序内的显示图像
    #((16, 16), (0, 0), (0, 0, 64, 0, 96, 0, 112, 0, 120, 0, 124, 0, 126, 0, 127, 0, 127, 128, 124, 0, 108, 0, 70, 0, 6, 0, 3, 0, 3, 0, 0, 0), (192, 0, 224, 0, 240, 0, 248, 0, 252, 0, 254, 0, 255, 0, 255, 128, 255, 192, 255, 224, 254, 0, 239, 0, 207, 0, 135, 128, 7, 128, 3, 0))

  • 相关阅读:
    1166
    SpringBoot(八) Caching
    将本地项目上传到码云
    《码出高效 Java开发手册》
    Sourcetree报错: 您没有已经配置扩展集成设置的远端
    看准网免登陆查看
    redis入门基础
    Java泛型类型
    SpringBoot(七) Working with data: SQL
    ORA-12514: TNS:监听程序当前无法识别连接描述符中请求的服务
  • 原文地址:https://www.cnblogs.com/liming19680104/p/13140810.html
Copyright © 2020-2023  润新知