0
playerOnePosition = (WINDOWHEIGHT - PADDLESIZE) /2
y = 0
moveY = 0
#Creates Rectangles for ball and paddles.
paddle1 = pygame.Rect(PADDLEOFFSET,(playerOnePosition,(y)), LINETHICKNESS,PADDLESIZE)
drawPaddle(paddle2)
clock = pygame.time.Clock()
while True: #main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
# mouse movement commands
if (event.type == pygame.KEYDOWN):
if(event.key == pygame.K_DOWN):
moveY = -5
if (event.key == pygame.K_UP):
moveY = 5
if (event.type == pygame.UP):
if(event.key == pygame.K_DOWN):
moveY = 0
if (event.key == pygame.K_UP):
moveY = 0
y += moveY
clock.tick(50)
我的代码的这部分工作不正常,我试图设置键使桨上下移动,但我无法弄清楚我的代码出了什么问题。参数必须是矩形对象
的错误是:Argument must be rect style object
您能否提供[MCVE](http://stackoverflow.com/help/mcve)? – Adalee
@Adalee我是新来的,我已经做对了吗? –
@Joaqin如果我复制你的代码,由于变量的导入和声明,它无法运行。因为我们无法确定你的变量包含什么(例如'LINETHICKNESS'),所以我们不能告诉你究竟是什么错误。 – Adalee