That’s what I was talking about. But this is not wise.
from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import DirectButton
from direct.task import Task
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.mySound = base.loader.loadSfx("shot.ogg")
self.mySound1 = base.loader.loadSfx("shot1.ogg")
self.mySound2 = base.loader.loadSfx("shot2.ogg")
self.mySound3 = base.loader.loadSfx("shot3.ogg")
self.mySound4 = base.loader.loadSfx("shot4.ogg")
self.mySound5 = base.loader.loadSfx("shot5.ogg")
self.mySound6 = base.loader.loadSfx("shot6.ogg")
self.accept('space', self.shot)
a = DirectButton(text = ("OK"),rolloverSound = self.mySound, pos = (-0.2, 0, 0),scale=.05, command=None)
s = DirectButton(text = ("OK"),rolloverSound = self.mySound1, pos = (-0.2, 0, -0.05), scale=.05, command=None)
d = DirectButton(text = ("OK"),rolloverSound = self.mySound2, pos = (-0.2, 0, -0.1), scale=.05, command=None)
f = DirectButton(text = ("OK"),rolloverSound = self.mySound3, pos = (-0.2, 0, -0.15), scale=.05, command=None)
g = DirectButton(text = ("OK"),rolloverSound = self.mySound4, pos = (-0.2, 0, -0.2), scale=.05, command=None)
h = DirectButton(text = ("OK"),rolloverSound = self.mySound5, pos = (-0.2, 0, -0.25), scale=.05, command=None)
j = DirectButton(text = ("OK"),rolloverSound = self.mySound6, pos = (-0.2, 0, -0.3), scale=.05, command=None)
a1 = DirectButton(text = ("OK"),rolloverSound = self.mySound, pos = (0.2, 0, 0),scale=.05, command=None)
s2 = DirectButton(text = ("OK"),rolloverSound = self.mySound, pos = (0.2, 0, -0.05), scale=.05, command=None)
d3 = DirectButton(text = ("OK"),rolloverSound = self.mySound, pos = (0.2, 0, -0.1), scale=.05, command=None)
f4 = DirectButton(text = ("OK"),rolloverSound = self.mySound, pos = (0.2, 0, -0.15), scale=.05, command=None)
g5 = DirectButton(text = ("OK"),rolloverSound = self.mySound, pos = (0.2, 0, -0.2), scale=.05, command=None)
h6 = DirectButton(text = ("OK"),rolloverSound = self.mySound, pos = (0.2, 0, -0.25), scale=.05, command=None)
j7 = DirectButton(text = ("OK"),rolloverSound = self.mySound, pos = (0.2, 0, -0.3), scale=.05, command=None)
def shot(self):
self.mySound.play()
app = MyApp()
app.run()
On the right side is your approach. And on the left - fix this problem. However, in the audio manager, the same sound refuses to copy during the new playback, it just plays again. This is a limitation of the audio manager, I think it needs fixing.