|
It isn't really neccessary to know about 'particle slots' when
working with the Particle Candy engine, but it's a very nice,
additional feature.
What are particle slots? In the 'feeding emitters' chapter, you
learned that each emitter can hold up to 10 different particle
types (by default). This means that each emitter has ten empty
slots when created. The purpose of a slot is simply to hold
a particle type. Each time you add a particle type to
the emitter, it will be assigned to the next empty slot.
The cool thing now is that you can enable or disable each slot
at any time! For example: Let's assume that you created an emitter
and attached two different particle types to it -smoke and fire. By using the
command Emitter_AddParticleType(), each particle type has been
assigned automatically to the next free slot of the emitter.
Now launch the emitter. You will see -well, fire and smoke, both
together. By disabling the slot that holds the smoke particle type,
for example, you can stop the smoke emission immediately and
by enabling this slot again, the emitter will resume to emit
smoke particles. It's as easy. Simply explained, you can enable or
disable each of an emitter's particle types individually.
ParticleType1 = CreateParticleType()
ParticleType2 = CreateParticleType()
MyEmitter = CreateEmitter()
Slot1% = Emitter_AddParticleType(MyEmitter, ParticleType1,... ...)
Slot2% = Emitter_AddParticleType(MyEmitter, ParticleType2,... ...)
Each time you add a particle type to an emitter, the slot
number of this particle type will be returned. You are free
to save this 'handle' to a variable, or not. It may be useful,
however, if you'd like to access those slots later (don't forget
to use the brackets here, otherwise the command won't return
anything).
If you saved the slot numbers, this is how to enable or disable
the emission of a certain particle type (a.k.a slot):
; DISABLE:
Emitter_DisableSlot MyEmitter, Slot1
; ENABLE:
Emitter_EnableSlot MyEmitter, Slot1
You can check the state of a slot at any time. Example:
If Emitter_SlotEnabled (MyEmitter, Slot1) = True Then ...
This command returns FALSE if the slot has been disabled
or TRUE if the slot is enabled. Don't forget to use brackets
here, otherwise Blitz won't return any value.
|