当我尝试运行Python时,它说语法无效,并向我显示了这段代码:def drawTitle(self, (x, y)):
。更具体地说,错误来自(x , y)
括号中。我正在使用python版本3.7。
# writes and positions the title
def drawTitle(self, (x, y)):
font = pygame.font.Font("Chalkduster.ttf",80)
textDisplay = font.render("Checkers", True, red)
textRect = textDisplay.get_rect()
textRect.center = (x, y)
self.startWnd.blit(textDisplay, textRect)
代码未执行并显示警报:“无效语法”
答案 0 :(得分:0)
您可以编写如下代码:
def drawTitle(self, t):
# x, y = t
font = pygame.font.Font("Chalkduster.ttf",80)
textDisplay = font.render("Checkers", True, red)
textRect = textDisplay.get_rect()
textRect.center = t
self.startWnd.blit(textDisplay, textRect)
# call: drawTitle((10,12))