简体   繁体   English

调用blit方法和pygame.display.update函数时无法渲染Surface对象

[英]I can't render a Surface object when calling blit method and pygame.display.update function

I can't say I'm new to pygame. 我不能说我是pygame的新手。 But this is just wierd. 但是,这很奇怪。 I am currenty working on a medium-sized project and while testing I found a wierd bug: Surface object won't render upon calling pygame.display.update() 我目前正在研究一个中型项目,并且在测试时发现了一个奇怪的错误:调用pygame.display.update()时,Surface对象无法渲染

Using Python 3.7.0 使用Python 3.7.0

I even tested this: 我什至对此进行了测试:

import pygame
from pygame.locals import *
pygame.init()

s = pygame.display.set_mode((800, 600))
a = pygame.image.load('black_rectangle.png')

while True:
    for event in pygame.event.get():
        if event.type == QUIT:
                pygame.quit()
                quit()
    s.fill((255, 255, 255))
    a.blit(s, (400, 300))
    pygame.display.update()

And all I could see was just a empty white screen. 我所看到的只是空白的屏幕。

You are blitting the white s surface onto the black a surface. 您正在将白色s表面刮涂到黑色a表面上。 Just swap s and a . 只需交换sa

s.blit(a, (400, 300))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM