【发布时间】:2020-06-01 03:23:33
【问题描述】:
所以我正在将声音加载到我的游戏中,但我收到了这个错误 我正在使用 python 3 windows 10
pygame.error: mixer not initialized
我试过推杆,但当我推杆时,我得到了
pygame.mixer.init()
当我把 pygame.mixer.init() 我得到这个错误?我必须导入一些东西吗??
pygame.error: DirectSoundCreate: No audio device found
import pygame
import math
pygame.init()
pygame.mixer.init()
# window
window = pygame.display.set_mode((800,800))
pygame.display.set_caption("new World")
#
# error bloccks
erblock = pygame.image.load("error.png")
# trees images
treo = pygame.image.load("tree.png")
# mountains
mounto = pygame.image.load("mount.png")
# platform images
blocks = pygame.image.load("block.png")
# coins image
heart = pygame.image.load("heart.png")
# heart image
heartingss = pygame.image.load("health.png")
# define the shooting sound for the player ------------------------
shootsound = pygame.mixer.Sound("ss.wav")
# hit enemy sound
hitenemysound = pygame.mixer.Sound("hitenemy.wav")
# sound for jumping
jumpsound = pygame.mixer.Sound("sjump.wav")
# pick up coins sound
coinssound = pygame.mixer.Sound("coinssound.wav")
# shoot sound
shots = pygame.mixer.Sound("shootsound.wav")
# hit the ice sound
icehit = pygame.mixer.Sound("h.wav")
# health power UP
powerup = pygame.mixer.Sound("pw.wav")
# load this sound if the player is dead
death = pygame.mixer.Sound("death.wav")
# walking sound
walk = pygame.mixer.Sound("walks.wav")
# background music
music = pygame.mixer.Sound("backgroundsong.wav")
pygame.mixer.music.play(-1)
【问题讨论】:
-
您能否编辑您的问题以包括操作系统和 Python + PyGame 版本
-
是的,我添加了它我使用 python 3 windows 10
标签: python python-3.x audio pygame