在我的玩偶档案里有:
from livewires import games
import math, random
class Ship(games.Sprite):
image = games.load_image("images\ship.bmp", transparent = True)它给出了错误:
pygame error: No video mode has been set我使用livewires来导入游戏,而这个post没有给我的计算机一个正确的答案。
发布于 2015-02-23 20:38:40
您需要初始化livewires显示,如下所示:
from livewires import games
import math, random
games.init(screen_width = 640, screen_height = 480, fps = 60)
# game logic here
games.screen.mainloop() # mainloop of the display发布于 2015-02-23 20:22:30
就像那个帖子说的,你需要设置
screen = pygame.display.set_mode((800, 600)) # change to the real resolution在您的ship类之外的某个地方(比如您的主要方法)。您的ship类用于在游戏中生成对象,而不是创建游戏窗口。
如果要将所有类保存在一个文件中,请尝试如下所示:
from pygame.locals import *
from livewires import games
import math, random
def main():
pygame.init()
screen = pygame.display.set_mode((800, 600)) # change to the real resolution
class Ship(games.Sprite):
image = games.load_image("images\ship.bmp", transparent = True)
if __name__ == '__main__':
main()https://stackoverflow.com/questions/28682570
复制相似问题