python - 当我在 pygame 中绘制图像时,我看不到我的图像,即使它与我的 python 脚本和脚本所需的其他 python 模块位于同一文件夹中
问题描述
我正在制作一个 python 程序,我想使用模块 pygame 在我的屏幕/表面上绘制图像,但是当我尝试绘制图像时,我看不到它。该图像与我的 python 脚本位于同一文件夹中,因此这不应该是问题。我的语法也是正确的。所以我不知道,如果有人回应我将不胜感激。谢谢!
import pygame,sys
pygame.init()
clock = pygame.time.Clock()
screen=pygame.display.set_mode((800,800))
second_surface=pygame.Surface([100,200])
second_surface.fill((0,0,255))
isaac=pygame.image.load('isaac.png')
while True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
pygame.quit()
sys.exit()
screen.fill((255,255,255))
screen.blit(second_surface,(0,50))
isaac.blit(isaac,(100,200))
pygame.display.flip()
clock.tick(60)
解决方案
Rabbid76 的回答:
isaac.blit(isaac,(100,200))
它说它应该在哪里screen.blit(isaac,(100,200))
。
推荐阅读
- php - 服务器更改后 PHP opendir/get_files 不起作用
- ruby - Cocoapods Traceback 在 41 个 gem(s) (Gem::MissingSpecError) 中找不到 'json' (>= 1.5.1)
- python - 如何按升序显示 Y 上的值,但保存它们的索引。Matplotlib
- java - 在不知道密钥但知道明文将包含的单词之一的情况下解密移位密码的方法-Java
- c - 带哨兵的链表
- javascript - 在 for() 循环中编辑变量的值
- php - wp_nav_menu 如何将整个子菜单包装在 div 中
- bootstrap-4 - Bootstrap 4 导航栏切换按钮是否可以在打开另一个菜单之前关闭先前打开的菜单?
- python - 如何避免 pytest 设备中的状态依赖?
- android - Android Studio 4.1.1“运行”不编译代码