sound.Player in scene
Is it possible to get a sound.Player to play in a scene? I have tried the following code in the setup method:
music_player = sound.Player(file_path) music_player.play()
But it does not work.
sound.play_effect(file_path)does work though, and both of these work when not presented in a scene. Is there a way to make it work?
The problem is probably that
music_playeris a local variable, and falls out of scope (gets garbage-collected) when the
setupmethod returns. Try
self.music_player = ...instead to make it an attribute of the scene.
Ah yes, forgot about that. Works fine now.