我会努力工作,提高测试技能。

python学习笔记---事件

上一篇 / 下一篇  2014-07-03 22:03:49 / 个人分类:python学习

1Keyboard events

      KEYDOWN

      KEYUP

2key names

      K_a,K_b(for letter keys)

      K_SPACE

      K_ESCAPE

3Mouse events

      MOUSEMOTION

      MOUSEBUTTONUP

     MOUSEBUTTONDOWN

4event.posthe positionx and y coordinates

5Timer events

      pygame.time.set_timer(EVENT_NUMBER,interval)

     获取pygame的已用事件:

     >> import pygame

     >>pygame.USEREVENT

     输出结果:24

     说明已用事件从023,可用的userevent24开始。

     获取pygame的最大事件类型:

     >>pygame.NUMEVENTS

     输出结果:32

     说明可用的事件从031,那么可用的userevent2431

     通常使用方法:

     Pygame.time.set_timer(pygame.USEREVENT,1000)

     备注:1000是指毫秒为单位。

6\:是line-contination character.使用这个符号可以用两行显示,但是还是表示在同一行的意思。一般这个符号在        一行结尾使用,但是这个符号后不能有空格。

  7display text的对象:

     font = pygame.font.Font(None,50)

    score_text = font.render(str(points),1,(0,0,0))

    textpos = [10,10]

    screen.blit(score_text,textpos)

 

8、创建一个surface

    image_surface = pygame.surface.Surface([100,20])

    image_surface.fill([0,0,0])

    self.image = image_surface.convert()

    self.rect = self.image.get_rect()

    self.rect.left,self.rect.top = location

9paddle:一段代码只处理一个事件。比如创建8surface

 


TAG:

 

评分:0

我来说两句

Open Toolbar