简体   繁体   English

Pygame 不会在 M1 MacBook Air 上初始化游戏 Window

[英]Pygame Won't Initialize Game Window on M1 MacBook Air

I just bought an M1 MacBook Air today for coding a pygame project, but at very beginning I had an issue with pygame video system.我今天刚买了一台 M1 MacBook Air 来编写 pygame 项目,但一开始我遇到了 pygame 视频系统的问题。 it won't initialize pygame window.它不会初始化 pygame window。 The following code snippet works in PC, but M1 Mac just won't initialize it.以下代码片段适用于 PC,但 M1 Mac 不会初始化它。 the error message I got is "pygame error: video system not initialize"我收到的错误消息是“pygame 错误:视频系统未初始化”

I am not sure if this issue is just for M1 Mac or it is an issue for all Mac users.我不确定这个问题是只针对 M1 Mac 还是针对所有 Mac 用户。 Does anyone know the answer and solution for this error?有谁知道这个错误的答案和解决方案?

Thank you very much!非常感谢!

    import pygame
    pygame.init() 
    screen = pygame.display.set_mode((800, 600))
    run = True
    while run:
       for event in pygame.event.get():
          if event.type == pygame.quit():
             run = False

I initially thought this was an M1 mac problem, since pygame doesn't have good support for M1 mac yet.我最初认为这是一个 M1 mac 问题,因为 pygame 还没有对 M1 mac 有很好的支持。

However I see the problem:但是我看到了问题:

if event.type == pygame.quit():

should be应该

if event.type == pygame.QUIT

Right now you're running the function pygame.quit() , which uninitializes your video system.现在您正在运行 function pygame.quit() ,它会取消初始化您的视频系统。

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

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