我刚刚开始了一个小游戏项目,我试图让它在每次发射子弹时发出声音,但我一直得到同样的错误:
pygame.error:混音器系统未初始化
我不知道我做错了什么,这是我的代码:
pygame.error: mixer system not initialized
Run Code Online (Sandbox Code Playgroud)
....
import pygame, sys
from pygame.locals import *
theClock = pygame.time.Clock()
sound = pygame.mixer.Sound("bullet.mp3")
Run Code Online (Sandbox Code Playgroud) 我已经设置了相机,效果很好。问题是,当我尝试导入pygame时,出现ModuleNotFoundError。(注意:我正在使用Windows)
这是一个测试项目,我必须用pygame制作相机。我已经尝试了一些youtube教程,但将pygame弄乱了,但始终会导致错误。
这是我到目前为止的内容:
import pygame.camera
pygame.camera.init()
camera = pygame.camera.list_cameras()[0]
pyg = pygame.camera.Camera(camera (640, 480), 'HSV')
--snip--
if pyg.query_image():
win.blit(pyg.get_image(surface=win), (0, 0))
pygame.quit()
Run Code Online (Sandbox Code Playgroud)
每次尝试都导致相同的错误。错误消息是:
Traceback (most recent call last):
File "C:\Users\roche\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygame\_camera_vidcapture.py", line 31, in init
import vidcap as vc
ModuleNotFoundError: No module named 'vidcap'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\roche\Documents\pygame_camera.py", line 5, in <module>
pygame.camera.init()
File "C:\Users\roche\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygame\camera.py", line 68, in init
_camera_vidcapture.init()
File "C:\Users\roche\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygame\_camera_vidcapture.py", line 33, in init
from VideoCapture import …Run Code Online (Sandbox Code Playgroud)