我必须写一个射箭得分程序,我一直收到这个错误: AttributeError:' int'对象没有属性' setText'
def main():
win = gameWindow()
currentShot, overallScore = scoreOverlay(win)
shot = 0
totalScore = 0
for i in range(5):
p = win.getMouse()
p.draw(win)
x = p.getX
y = p.getY
score = scoring(p)
currentShot.setText('Current Shot: {0:1}'.format(scoring))
overallScore = 'overallScore' + 'currentShot'
overallScore.setText('Total{0:1}'.format(overallScore))
main()
任何想法如何解决这个问题?我不在这个问题上。 提前感谢您提供的任何帮助。
答案 0 :(得分:0)
下面; currentShot = 0
在这里; overallScore = 0
您将currentShot和overallScore设置为整数。它们不再分别等于Text(Point(175,13), 'Current Shot: ')
和Text(Point(175,340), 'Total: ')
。为currentShot = 0
和overallScore = 0
中的变量使用不同的变量名称,这应该可以解决您的错误