With a bit of a java background I’ve been learning panda and python for the last few weeks and have been able to set up some basic world, chasecam and basic physics and ‘even’ a loading screen, based initially on the roaming ralph example supplied with the engine.
I have however had a problem that I was unable to solve until today and now I’m quite curious as to what causes it and if its supposed to be this way.
In every panda example I’ve seen, there is just one class, which might or might not contain a class and has a run() function at the bottom.
In my game, I’m starting out with a main-like class, which loads an instance of ‘LoadingScreen’ and draws a button:
button = DirectButton(image = settings.TEXTUREPATH + "button.jpg", scale = 0.1, pos = (.0,.8, -0.7), command=loadWorld)
The init function that is called, will instantiate a number of other classes, which take care of loading the world, background music, a player character, a keyMapper, menu’s etc.
Everything works fine with this. That is, models are loaded ok, the keyMapper works, I can move around my character, the camera works as intended… There is just one problem: I could not hear any sound and non-player characters did not show any animation, despite the fact that [sound].status did return ‘2’ which, according to the manual, means that the sound is playing. Sound itself is ok, I can hear the default sound when pressing a button.
After a few days of tinkering, I found that if I called the .loop(“animation”) on an actor or the .play() function on a sound from a Task, it would work. The task itself needs to be like this to work:
def runSound(self, task): if not self.sounding: self.mySound1.play() self.sounding = True return Task.cont
Ofcourse, creating a task for every sound I want to play and doing the same for animations, would be a bit… redundant (though I can of course restart the same task for different sounds). Over all, it just feels wrong…
can anyone enlighten me as to whether this is the intended way to do this? I have as of yet not been able to find any information regarding this ‘problem’ on the forum or the manual. Could I be doing something wrong at an earlier stage?