
- Pygame 教程
- Pygame - 首页
- Pygame - 概述
- Pygame - Hello World
- Pygame - 显示模式
- Pygame - Locals 模块
- Pygame - 颜色对象
- Pygame - 事件对象
- Pygame - 键盘事件
- Pygame - 鼠标事件
- Pygame - 绘制形状
- Pygame - 加载图像
- Pygame - 在窗口中显示文本
- Pygame - 移动图像
- Pygame - 使用数字小键盘移动
- Pygame - 使用鼠标移动
- Pygame - 移动矩形对象
- Pygame - 使用文本作为按钮
- Pygame - 图像变换
- Pygame - 音效对象
- Pygame - 混音器通道
- Pygame - 播放音乐
- Pygame - 播放视频
- Pygame - 使用摄像头模块
- Pygame - 加载光标
- Pygame - 访问CDROM
- Pygame - 精灵模块
- Pygame - PyOpenGL
- Pygame - 错误和异常
- Pygame 有用资源
- Pygame - 快速指南
- Pygame - 有用资源
- Pygame - 讨论
Pygame - 加载光标
Pygame 允许你控制系统光标。Pygame 只可以使用黑白光标。pygame.cursors 模块定义了预定义的光标枚举。
- pygame.cursors.arrow
- pygame.cursors.diamond
- pygame.cursors.broken_x
- pygame.cursors.tri_left
- pygame.cursors.tri_right
箭头光标是默认选择。要使用其他光标,我们使用 pygame.mouse 模块中的 set_cursor() 函数。
pygame.mouse.set_cursor(pygame.cursors.broken_x)
示例
在下面的示例中,此光标可以在显示窗口中看到。
import pygame,sys from pygame.locals import * pygame.init() pygame.mouse.set_cursor(pygame.cursors.broken_x) canvas=pygame.display.set_mode((400,300)) pygame.display.set_caption("Cursor") while True: for event in pygame.event.get(): if(event.type == QUIT): pygame.quit() sys.exit(1)
输出

此模块还包含一些格式化为字符串的光标。要使用它们,请使用 pygame.cursors.compile() 函数。
- pygame.cursors.thickarrow_strings
- pygame.cursors.sizer_x_strings
- pygame.cursors.sizer_y_strings
- pygame.cursors.sizer_xy_strings
- pygame.cursor.textmarker_strings
cursor = pygame.cursors.compile(pygame.cursors.textmarker_strings) pygame.mouse.set_cursor((10,10), (0, 0), *cursor)
广告