간단한 객체 지향 탁구 게임을 만들려고합니다. 나는 Player
객체와 하나의 메소드 (create_paddle
)를 가지고있다. 나는 create_paddle
방법을 Player
의 인스턴스를 생성하고 호출 할 때 그것은 나에게 다음과 같은 오류를 제공합니다 :자체 속성이 작동하지 않습니다. 파이썬
Traceback (most recent call last):
File "C:\Users\jerem\Documents\python_programs\pong.py", line 30, in <module>
player1.create_paddle(30, 180, 15, 120)
TypeError: create_paddle() missing 1 required positional argument: 'h'
프로그램 : 나는 오류를보고하고 다른 게시물이 도움이되지
class Player:
def create_paddle(self, x, y, w, h):
pygame.draw.rect(surface, white, (x, y, w, h))
player1 = Player
player1.create_paddle(30, 180, 15, 120)
. 도움을 주시면 감사하겠습니다. 감사합니다, JC
객체 생성 할 때 괄호를 놓치고
'player1 = 플레이어()' – Li357