Pygame 지 않는 블록 전송 이미지 대신 뱉 error 유형

0

질문

그래서 나는 이것을 보는 튜토리얼에 대한 온라인 pygame 으로 나는 극단적으로 새로운 pygame. 그래서 그가 무엇이었을 만들어 플레이어()함수 및 다음 blit 니다. 그래서 저도 그랬습니다. 그를 위해,그는 그것을 얻을 완벽하게 blitted 지만,나에게,나를 얻을 입력 오류가 있습니다. 는 유일한 것 서로 다른 사이에 자신의 코드 및 광산은 차원의 창과 플레이어스 클래스고 있습니다. 어린이,어린이와 청소년 그것은 여기에서 stack overflow,하지만에만 관련 질문을 받을 수 없습니다. 지 무엇을 잘못했습니다.

전체 오류가:

/home/Command Blocks/Desktop/venv/bin/python "/home/CommandBlocks/Desktop/CLASS_/Studies/Computer/python/practice/space shooter/main.py"
pygame 2.0.2 (SDL 2.0.16, Python 3.9.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "/home/Command Blocks/Desktop/CLASS_/Studies/Computer/python/practice/space shooter/main.py", line 33, in <module>
    player()
  File "/home/Command Blocks/Desktop/CLASS_/Studies/Computer/python/practice/space shooter/main.py", line 20, in player
    screen.blit(player, (playerX, playerY))
TypeError: argument 1 must be pygame.Surface, not function

Process finished with exit code 1

전체 코드:

import pygame

#Initialize pygame module
pygame.init()

#Create Screen
screen = pygame.display.set_mode((1000, 600))

#Title and Icon
pygame.display.set_caption("Jungle Invader")
icon = pygame.image.load('fox-sitting.png')
pygame.display.set_icon(icon)

# Player
player = pygame.image.load('cat.png')
playerX = 300
playerY = 500

def player():
    screen.blit(player, (playerX, playerY))


#Main loop
running = True
while running:
    pygame.display.update()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    screen.fill((244, 232, 255))
    player()
pygame python python-3.x
2021-11-23 13:55:58
1

최고의 응답

0

당신은 이름을 이용 플레이어 두 배. 그것은 표면에서 반환 pygame.image.load('cat.png') 과하는 기능 blits 하여 화면입니다. 이름 player 기능 drawPlayer

2021-12-22 18:50:39

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................