screen.blit 功能在 pygame 中不起作用

问题描述

import pygame,sys

WINDOW_SIZE = (900,700)
screen = pygame.display.set_mode(WINDOW_SIZE,32)
pygame.display.set_caption('Pygame Program')
pygame.display.set_icon(pygame.image.load('spaceship (3).png'))

player_img = pygame.image.load('ClipartKey_738895_adobespark.png')
player_X = 130
player_Y = 750
def player():
    screen.blit(player_img,(player_X,player_Y))

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
            sys.exit()
    screen.fill((0,200,255))
    player()
    pygame.display.update()

我的 player() 函数不起作用。 它没有显示任何错误,但屏幕保持空白,没有显示任何内容

解决方法

坐标 (130,750) 位于窗口的底部外侧。更改 y 坐标。例如:

player_Y = 750

player_Y = 150