Python Pygame操纵杆不会更新

时间:2016-05-07 02:36:18

标签: python python-3.x while-loop pygame

我无法通过更新操纵杆轴来打印当前值。尝试了pygame操纵杆测试,这是有效的,所以它不是一个操纵杆问题。

谢谢

let id_m = Methods.Select(m => new { m.SimpleName, m.SimpleName.Length })
let id_f = Fields.Select(f => new { f.Name, f.Name.Length })
select id_m.Union(id_f)

输出保持0.0:

import pygame

pygame.init()
clock = pygame.time.Clock()

class JoyStick():

    def __init__(self):
        pass

    def update(self):
        joystickOne = pygame.joystick.Joystick(0)
        joystickOne.init()
        self.axisOne = joystickOne.get_axis(1)

OP = JoyStick()

while True:
    OP.update()
    print(OP.axisOne)
    clock.tick(10)

1 个答案:

答案 0 :(得分:0)

解决了!忘了事件处理程序。

while done==False:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done=True