Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pygame中的背景不工作_Python_Pygame - Fatal编程技术网

Python pygame中的背景不工作

Python pygame中的背景不工作,python,pygame,Python,Pygame,基本材料 import pygame import sys import os 我认为这可能是一个问题: 在互联网上,我看到了一些带有.convert()的东西,但它一直在告诉我: AttributeError:“str”对象没有属性“convert” 当我尝试放置.conver()时 已经搜索了2个小时,我找不到这个noob的东西 ''' Objects ''' # put Python classes and functions here ''' Setup #...

基本材料

import pygame
import sys   
import os     
我认为这可能是一个问题:

在互联网上,我看到了一些带有.convert()的东西,但它一直在告诉我: AttributeError:“str”对象没有属性“convert”

当我尝试放置.conver()时

已经搜索了2个小时,我找不到这个noob的东西

'''
Objects
'''

# put Python classes and functions here

'''
Setup #...
'''
# put run-once code here


fps = 60
ani = 4
clock = pygame.time.Clock()
pygame.init()

或在此:

'''
Main Loop
'''


你能把代码显示在你想把
convert()。导致错误的部分丢失。没有错误,游戏只有白色背景,而不是my backgroundbackground=pygame.image.load(os.path.join('background.png').convert())
'''
Main Loop
'''
world.blit(background, (0,0))
while main == True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit(); sys.exit()
            main = False

        if event.type == pygame.KEYDOWN:
            if event.key == ord('q'):
                pygame.quit()
                sys.exit()  
                main = False 

pygame.display.flip()
clock.tick(fps)