pygame'LEFT'未定义 [英] Pygame 'LEFT' is not defined

查看:193
本文介绍了pygame'LEFT'未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm working on a game. I have pygame imported. I am using Python 3.3 and Pygame 3.3. The same error message all the time "LEFT" is not defined. I did exact copies of what were on the internet as I already did a search for the problem. Here is my code. I have tried a few different ways and neither seem to work.

方法1:

import pygame
event = pygame.event.poll()
if event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT:
    ....command

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

method 2: (basically going all in)

from pygame import *
from pygame.locals import *
import pygame
event = pygame.event.poll()
if event.type == MOUSEBUTTONDOWN and event.button == LEFT:
    ......command

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

Before telling me, on both those methods I tried switching between "LEFT" and "pygame.LEFT", and so on.

有什么想法吗?

非常感谢.

推荐答案

自定义LEFT:

LEFT = 1

我认为 Pygame教程您所遵循的正是那样.换句话说,pygame库没有此值的常数,它只是一个整数.

The Pygame tutorial I think you are following does exactly that. In other words, the pygame library has no constants for this value, it's just an integer.

这篇关于pygame'LEFT'未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆