pygame を使用して作成されたゲーム用に Python で小さなテキスト クラスを作成しましたが、何らかの理由で既定の引数が機能しません。Pythonのドキュメントを見て、何が間違っていたのかを理解できるかどうかを確認しようとしましたが、ドキュメントの言語を完全には理解していませんでした. 他の誰もこの問題を抱えていないようです。
テキスト クラスのコードは次のとおりです。
class Text:
def __init__(self,screen,x_location='center',y_location='center',writeable,color,size=12):
self.font = pygame.font.Font("Milleni Gem.ttf", size)
self.text = self.font.render(writeable,True,color)
self.textRect = self.text.get_rect()
if x_location == "center":
self.textRect.centerx = screen.get_rect().centerx
else:
self.textRect.x = x_location
if y_location == "center":
self.textRect.centery = screen.get_rect().centery
else:
self.textRect.y = y_location
self.update()
def update(self):
screen.blit(self.text,self.textRect)
これを呼び出すコードは次のとおりです。
from gui import *
Text(screen,75,75,currentweapon.clip)#currentweapon.clip is an integer
私が得るエラーはこれです:
SyntaxError: non-default argument follows default argument
コード内の行を指しdef __init__()
ます。このエラーは何を意味し、ここで何が間違っていますか?