TableOfContents

pygame.cursors

pygame中控制鼠标指针资源的模块

pygame提供了对系统硬件鼠标指针的控制。pygame只支持系统中黑白色的指针。你可以通过pygame.mouse模块控制指针。

这个cursors模块包含载入和解码各种不同格式指针的函数。这些函数允许你把指针很容易的保存在外部文件中,也很容易直接编码为字符串。

模块包括几个标准的鼠标指针。pygame.mouse.set_cursor需要好几个参数。所有那些参数都已经保存在一个元组中,可以这样调用

>>> pygame.mouse.set_cursor(*pygame.cursors.arrow)

这个模块还包含几个以格式化的字符串表示的指针。在你使用它们之前,需要把这些指针先传给pygame.cursors.compile函数。使用的例子是这样的:

>>> cursor = pygame.cursors.compile(pygame.cursors.textmarker_strings)
>>> pygame.mouse.set_cursor(*cursor)

以下变量是指针位图,可以作为指针使用。

以下这些字符串可以通过pygame.cursors.compile转换为指针位图:

1. pygame.cursors.compile

从字符串创建二进制指针数据

pygame.cursor.compile(strings, black='X', white='.', xor='o'): return data, mask

                thickarrow_strings = (               #sized 24x24
                  "XX                      ",
                  "XXX                     ",
                  "XXXX                    ",
                  "XX.XX                   ",
                  "XX..XX                  ",
                  "XX...XX                 ",
                  "XX....XX                ",
                  "XX.....XX               ",
                  "XX......XX              ",
                  "XX.......XX             ",
                  "XX........XX            ",
                  "XX........XXX           ",
                  "XX......XXXXX           ",
                  "XX.XXX..XX              ",
                  "XXXX XX..XX             ",
                  "XX   XX..XX             ",
                  "     XX..XX             ",
                  "      XX..XX            ",
                  "      XX..XX            ",
                  "       XXXX             ",
                  "       XX               ",
                  "                        ",
                  "                        ",
                  "                        ")

2. pygame.cursors.load_xbm

从xbm文件里面加载指针数据

pygame.cursors.load_xbm(cursorfile, maskfile=None): return cursor_args

pygame.joystick

1. pygame.joystick.init

2. pygame.joystick.quit

3. pygame.joystick.get_init

4. pygame.joystick.get_count

5. pygame.joystick.Joystick

            pygame.joystick.Joystick(id): return Joystick
                  Joystick.init - initialize the Joystick       initialize the Joystick
                  Joystick.quit - uninitialize the Joystick     uninitialize the Joystick
                  Joystick.get_init - check if the Joystick is initialized      check if the Joystick is initialized
                  Joystick.get_id - get the Joystick ID get the Joystick ID
                  Joystick.get_name - get the Joystick system name      get the Joystick system name
                  Joystick.get_numaxes - get the number of axes on a Joystick   get the number of axes on a Joystick
                  Joystick.get_axis - get the current position of an axis       get the current position of an axis
                  Joystick.get_numballs - get the number of trackballs on a Joystick    get the number of trackballs on a Joystick
                  Joystick.get_ball - get the relative position of a trackball  get the relative position of a trackball
                  Joystick.get_numbuttons - get the number of buttons on a Joystick     get the number of buttons on a Joystick
                  Joystick.get_button - get the current button state    get the current button state
                  Joystick.get_numhats - get the number of hat controls on a Joystick   get the number of hat controls on a Joystick
                  Joystick.get_hat - get the position of a joystick hat get the position of a joystick hat

5.1. Joystick.init

5.2. Joystick.quit

5.3. Joystick.get_init

5.4. Joystick.get_id

5.5. Joystick.get_name

5.6. Joystick.get_numaxes

5.7. Joystick.get_axis

5.8. Joystick.get_numballs

5.9. Joystick.get_ball

5.10. Joystick.get_numbuttons

5.11. Joystick.get_button

5.12. Joystick.get_numhats

5.13. Joystick.get_hat

pygame.time

1. pygame.time.get_ticks

2. pygame.time.wait

3. pygame.time.delay

4. pygame.time.set_timer

5. pygame.time.Clock

5.1. Clock.tick

5.2. Clock.tick_busy_loop

5.3. Clock.get_time

5.4. Clock.get_rawtime

5.5. Clock.get_fps

The End

ch3n2k.com | Copyright (c) 2004-2020 czk.