I'm trying to use mixer to play footsteps when the arrow keys are pressed. But whenever I do it obviously keeps detecting the button and continuously overlays the sound.
def walking():
walk = pygame.mixer.Channel(2)
walk_sound = mixer.Sound("Music/Walking.mp3")
walk.play(walk_sound)
if walk.get_busy():
# Don't play anything
This is the function for the walking sound. Is there a way to not play anything if there is a sound playing?
if keypress[K_RIGHT]:
self.rect.move_ip(x, 0)
self.image = walk_right[walk_count // frame_count]
display.blit(self.image, (self.rect.x, self.rect.y))
walk_count += 1
self.last = "right"
walking()
This is part of my Player class and Move method to show where I call the walking sound function.