mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
added AmbientSound
This commit is contained in:
parent
335370b515
commit
84e1b2ee2e
30
direct/src/level/AmbientSound.py
Executable file
30
direct/src/level/AmbientSound.py
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
from IntervalGlobal import *
|
||||||
|
import BasicEntities
|
||||||
|
|
||||||
|
class AmbientSound(BasicEntities.NodePathEntity):
|
||||||
|
def __init__(self, level, entId):
|
||||||
|
BasicEntities.NodePathEntity.__init__(self, level, entId)
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
BasicEntities.NodePathEntity.destroy(self)
|
||||||
|
|
||||||
|
def initSound(self):
|
||||||
|
if self.soundPath == '':
|
||||||
|
return
|
||||||
|
self.sound = base.loadSfx(self.soundPath)
|
||||||
|
if self.sound is None:
|
||||||
|
return
|
||||||
|
self.soundIval = SoundInterval(self.sound, node=self)
|
||||||
|
self.soundIval.loop()
|
||||||
|
|
||||||
|
def destroySound(self):
|
||||||
|
if hasattr(self, 'soundIval'):
|
||||||
|
self.soundIval.pause()
|
||||||
|
del self.soundIval
|
||||||
|
if hasattr(self, 'sound'):
|
||||||
|
del self.sound
|
||||||
|
|
||||||
|
if __dev__:
|
||||||
|
def attribChanged(self, *args):
|
||||||
|
self.destroySound()
|
||||||
|
self.initSound()
|
@ -13,6 +13,7 @@ import ModelEntity
|
|||||||
import PathEntity
|
import PathEntity
|
||||||
import VisibilityExtender
|
import VisibilityExtender
|
||||||
import PropSpinner
|
import PropSpinner
|
||||||
|
import AmbientSound
|
||||||
|
|
||||||
# some useful constructor functions
|
# some useful constructor functions
|
||||||
# ctor functions must take (level, entId)
|
# ctor functions must take (level, entId)
|
||||||
@ -32,6 +33,7 @@ class EntityCreator(EntityCreatorBase.EntityCreatorBase):
|
|||||||
EntityCreatorBase.EntityCreatorBase.__init__(self, level)
|
EntityCreatorBase.EntityCreatorBase.__init__(self, level)
|
||||||
self.level = level
|
self.level = level
|
||||||
self.privRegisterTypes({
|
self.privRegisterTypes({
|
||||||
|
'ambientSound': AmbientSound.AmbientSound,
|
||||||
'cutScene': CutScene.CutScene,
|
'cutScene': CutScene.CutScene,
|
||||||
'editMgr': EditMgr.EditMgr,
|
'editMgr': EditMgr.EditMgr,
|
||||||
'entityGroup': nothing,
|
'entityGroup': nothing,
|
||||||
|
@ -44,6 +44,7 @@ class EntityCreatorAI(EntityCreatorBase.EntityCreatorBase):
|
|||||||
cLE = createLocalEntity
|
cLE = createLocalEntity
|
||||||
|
|
||||||
self.privRegisterTypes({
|
self.privRegisterTypes({
|
||||||
|
'ambientSound': nothing,
|
||||||
'cutScene': nothing,
|
'cutScene': nothing,
|
||||||
'editMgr': Functor(cLE, EditMgrAI.EditMgrAI),
|
'editMgr': Functor(cLE, EditMgrAI.EditMgrAI),
|
||||||
'entityGroup': nothing,
|
'entityGroup': nothing,
|
||||||
|
@ -119,6 +119,12 @@ class VisibilityExtender(Entity):
|
|||||||
('newZones', [], 'visZoneList'),
|
('newZones', [], 'visZoneList'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class AmbientSound(Entity):
|
||||||
|
type = 'ambientSound'
|
||||||
|
attribs = (
|
||||||
|
('soundPath', '', 'bamfilename'),
|
||||||
|
)
|
||||||
|
|
||||||
class PropSpinner(Entity):
|
class PropSpinner(Entity):
|
||||||
type = 'propSpinner'
|
type = 'propSpinner'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user