I'm trying to create three sound channels for my game.
music = pygame.mixer.Channel(0)
ambience = pygame.mixer.Channel(1)
sfx = pygame.mixer.Channel(2)
The first two channels work perfectly. However, when calling the third one I get the error message:
AttributeError: 'dict' object has no attribute 'play'
I don't know why my 3rd channel is a dict instead of a channel object. Changing the amount of channels or order doesn't help.
This is my sound module.
import pygame
import os
pygame.mixer.init()
music = pygame.mixer.Channel(0)
ambience = pygame.mixer.Channel(1)
sfx = pygame.mixer.Channel(2)
def get_sound(folder, sound):
return pygame.mixer.Sound(os.path.join(os.path.dirname(__file__)+'\sounds',folder, sound))
sounds = {
'ambient_sailing': get_sound('ambient', 'ambience_sailing_06.mp3'),
'ambience_forest': get_sound('ambient', 'ambience_forest.mp3'),
'ambience_dwarf_stronghold': get_sound('ambient', 'ambience_dwarf_stronghold.mp3'),
'ambience_gnome_village': get_sound('ambient', 'ambience_gnome_village.mp3'),
'happy_vikings' : get_sound('music', 'happy_vikings.wav'),
'drifting' : get_sound('music', 'drifting.mp3'),
}
sfx = {
'ship_move' : get_sound('effects', 'ship_move_01.wav'),
'select_destination' : get_sound('effects', 'select_destination_01.wav'),
}