mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
*** empty log message ***
This commit is contained in:
parent
150f732829
commit
8f1605a30e
@ -6,6 +6,7 @@ from ActorInterval import *
|
||||
from FunctionInterval import *
|
||||
from LerpInterval import *
|
||||
from MopathInterval import *
|
||||
from ParticleInterval import *
|
||||
from SoundInterval import *
|
||||
from WaitInterval import *
|
||||
|
||||
|
56
direct/src/interval/ParticleInterval.py
Normal file
56
direct/src/interval/ParticleInterval.py
Normal file
@ -0,0 +1,56 @@
|
||||
"""ParticleInterval module: contains the ParticleInterval class"""
|
||||
|
||||
from PandaModules import *
|
||||
from Interval import *
|
||||
|
||||
import BattleParticles
|
||||
|
||||
class ParticleInterval(Interval):
|
||||
# Name counter
|
||||
particleNum = 1
|
||||
# create ParticleInterval DirectNotify category
|
||||
notify = directNotify.newCategory('ParticleInterval')
|
||||
# Class methods
|
||||
def __init__(self, particleEffect, parent, worldRelative=1, loop=0,
|
||||
duration=0.0, name=None):
|
||||
"""__init__(particleEffect, parent, worldRelative, loop, duration, name)
|
||||
"""
|
||||
# Generate unique name
|
||||
id = 'Particle-%d' % ParticleInterval.particleNum
|
||||
ParticleInterval.particleNum += 1
|
||||
if (name == None):
|
||||
name = id
|
||||
# Record instance variables
|
||||
self.particleEffect = particleEffect
|
||||
self.parent = parent
|
||||
self.worldRelative = worldRelative
|
||||
self.loop = loop
|
||||
assert(duration > 0.0 or loop == 1)
|
||||
# Initialize superclass
|
||||
Interval.__init__(self, name, duration)
|
||||
# Update stopEvent
|
||||
self.stopEvent = id + '_stopEvent'
|
||||
self.stopEventList = [self.stopEvent]
|
||||
|
||||
def updateFunc(self, t, event=IVAL_NONE):
|
||||
""" updateFunc(t, event)
|
||||
Go to time t
|
||||
"""
|
||||
# Update particle effect based on current time
|
||||
if (t >= self.getDuration()):
|
||||
# If duration reached or stop event received, stop particle effect
|
||||
BattleParticles.cleanupParticleEffect(self.particleEffect)
|
||||
self.ignore(self.stopEvent)
|
||||
elif (event == IVAL_INIT):
|
||||
# IVAL_INIT event, start new particle effect
|
||||
BattleParticles.startParticleEffect(self.particleEffect,
|
||||
self.parent, self.worldRelative)
|
||||
# Accept event to kill particle effect
|
||||
self.acceptOnce(self.stopEvent,
|
||||
lambda s = self:
|
||||
BattleParticles.cleanupParticleEffect(s.particleEffect))
|
||||
# Print debug information
|
||||
self.notify.debug('updateFunc() - %s: t = %f' % (self.name, t))
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user