Pygame - Sound delay

前端 未结 7 1239
广开言路
广开言路 2020-12-16 01:32

I\'ve made a button class that checks if a button is selected (when the mouse is hovering over the button). When the button is selected, unselected or clicked it plays a wav

相关标签:
7条回答
  • 2020-12-16 02:31

    I know this is old, but I found the best solution I have seen so far.

    The fix is quite simple actually. I used to have delay in my pygame projects all the time because I would initialize pygame before initializing the mixer. (which always seemed the way you should do it to me).

    However if you initialize the mixer before initializing pygame itself it gets rid of all delay. This fixed all my delay problems. hope it helps.

    pygame.mixer.pre_init(44100, -16, 2, 2048)
    pygame.mixer.init()
    pygame.init()
    
    0 讨论(0)
提交回复
热议问题