[Solved] Reset Particle Emitter?
Posted: Wed Mar 19, 2014 10:50 pm
I'm creating a particle explosion effect with several emitters and I only want to loop them once. I planned on just resetting them and then using the effect again when needed.
Unfortunately, I'm having trouble with the reset process. I couldn't find a command for an emitter reset. So, I tried making my own with the emission rate.
I tried setting the rate to 0 and then resetting the rates back to their original value, but that didn't seem to work right. Seemed like the emitters were no longer in sync.
If I absolutely have to. I can just recreate the emitters and that will reset them, but if possible I was hoping to avoid that route.
Does anyone have any ideas of how to reset emitters to their original state?
Any help is appreciated.
EDIT:
Resetting the emission rate does work. I just messed up the first time I tried it.
Here is Purebasic's particle example that I edited. Press Space to stop the emitters and then Press Space again to restart them.
Unfortunately, I'm having trouble with the reset process. I couldn't find a command for an emitter reset. So, I tried making my own with the emission rate.
I tried setting the rate to 0 and then resetting the rates back to their original value, but that didn't seem to work right. Seemed like the emitters were no longer in sync.
If I absolutely have to. I can just recreate the emitters and that will reset them, but if possible I was hoping to avoid that route.
Does anyone have any ideas of how to reset emitters to their original state?
Any help is appreciated.
EDIT:
Resetting the emission rate does work. I just messed up the first time I tried it.
Here is Purebasic's particle example that I edited. Press Space to stop the emitters and then Press Space again to restart them.
Code: Select all
#CameraSpeed = 1
IncludeFile "Screen3DRequester.pb"
Define.f KeyX, KeyY, MouseX, MouseY
EmissionRate=0
If InitEngine3D()
Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
LoadTexture(0, "flare.png")
CreateMaterial(0, TextureID(0))
DisableMaterialLighting(0, 1)
MaterialBlendingMode (0, #PB_Material_Add)
CreateParticleEmitter(0, 10, 1, 1, 0)
ParticleMaterial (0, MaterialID(0))
ParticleTimeToLive (0, 2, 2)
ParticleEmissionRate(0, 20)
ParticleSize (0, 30, 30)
ParticleColorRange (0, RGB(255,0,0), RGB(255, 0, 255))
CreateParticleEmitter(1, 10, 1, 1, 0)
ParticleMaterial (1, MaterialID(0))
ParticleTimeToLive (1, 2, 2)
ParticleEmissionRate(1, 20)
ParticleSize (1, 30, 30)
ParticleColorRange (1, RGB(255, 255, 0), RGB(0, 255, 0))
MoveParticleEmitter(1, -50, 0, 0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, 0, 0, 100, #PB_Absolute)
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
If KeyboardReleased(#PB_Key_Space)
If EmissionRate=0
ParticleEmissionRate(0, 0)
ParticleEmissionRate(1, 0)
EmissionRate=1
Else
ParticleEmissionRate(0, 20)
ParticleEmissionRate(1, 20)
EmissionRate=0
EndIf
EndIf
EndIf
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End