I’m having a problem replaying a SoundInterval. I cut the Interval off early by calling Interval.finish(). When I opt to replay the sound, I have tried to call either Interval. start() or Interval.resume(). Now, when I try and play the sound again, Panda crashes in both instances. Do I have to do anything special to set up the Sound Interval again for replay?
The code is for a Dialogue tree system. Once I exit the dialogue, and go back to speaking back to the NPC again, it crashes on replaying the sound.
Here’s my code for the tree traversal and SoundInterval.
def dialogueTraversal(self,TraversalList,node):
if(node[1]):
self.exitDialogue()
elif(len(node[2]) > 0):
self.planeTalkBar.setTexture(self.planeTexTalkBar[1],1)
#NPCspeech has a string for NPC dialogue
NPCspeech = node[0]
print "NPC" , NPCspeech
NPCspeech = NPCspeech.encode('ascii')
self.talkTextNPC['text'] = NPCspeech
self.talkTextNPC.component('text0').setWordwrap(15.0)
self.talkTextNPC.show()
#PClist will have a list of all the PC dialogue strings to display
self.PClist=node[2].keys()
print "PC",self.PClist
PCspeech = '\n'.join(self.PClist)
PCspeech = PCspeech.encode('ascii')
self.talkTextPC['text'] = PCspeech
self.talkTextPC.show()
self.NPCVoiceInt = SoundInterval(node[3], volume=1)
self.NPCVoiceInt.start()
self.PClistLength = len(self.PClist)
#select which dialogue
self.choiceIndex = 0;
self.selectedString = self.PClist[self.choiceIndex]
self.currentNode=node
self.TraversalList = TraversalList
else:
parent = TraversalList.pop()
parent[0]=self.selectedNode[0]
self.dialogueTraversal(TraversalList,parent)
def dialogueChoice(self):
self.talkTextNPC.hide()
self.talkTextPC.hide()
self.NPCVoiceInt.finish()
self.TraversalList.append(self.currentNode)
self.selectedNode = self.currentNode[2][self.selectedString]
del self.currentNode[2][self.selectedString]
self.dialogueTraversal(self.TraversalList,self.selectedNode)