Pygame'LEFT'未定义

Gre*_*ory 0 python pygame mouseevent python-3.x

我正在做一个游戏.我有pygame导入.我使用的是Python 3.3和Pygame 3.3.始终没有定义相同的错误消息"LEFT".我已经对互联网上的内容进行了精确复制,因为我已经对问题进行了搜索.这是我的代码.我尝试了几种不同的方式,似乎都没有效果.

方法1:

import pygame
event = pygame.event.poll()
if event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT:
    ....command
Run Code Online (Sandbox Code Playgroud)

方法2 :(基本上全部进入)

from pygame import *
from pygame.locals import *
import pygame
event = pygame.event.poll()
if event.type == MOUSEBUTTONDOWN and event.button == LEFT:
    ......command
Run Code Online (Sandbox Code Playgroud)

在告诉我之前,在这两种方法中我尝试在"LEFT"和"pygame.LEFT"之间切换,依此类推.

有任何想法吗?

非常感谢.

Mar*_*ers 5

定义LEFT自己:

LEFT = 1
Run Code Online (Sandbox Code Playgroud)

我认为你关注的Pygame教程就是这样做的.换句话说,该pygame库没有该值的常量,它只是一个整数.