Usage
Particle Emitter
Constructionlocal emitYourParticle = require('Module Path Here') --(1)!
local ParticleEmitter = emitYourParticle.newEmitter(GuiObject) --(2)!
- Replace this with your module's path. Remove the single quotes.
- Put your emitter's GUI object here.
Properties
Note
All of these are read-only. Only index when reading the properties. Set the properties using methods.
Property Name |
Description |
Default |
GuiObject GuiObject |
The particle emitter's GUI Object |
GuiObject |
TemplateParticle GuiObject |
The particle emitter's particle |
nil |
Particles
{ Particle2D } |
An array of active particles |
{ } |
PropertyTransitions
{ PropertyTransition } |
An array of active property transitions |
nil |
AllPropertiesSet Boolean |
True if every ParticleEmitter:ApplyDefaultProperties() has been called |
false |
DoUpdateSize Boolean |
True if the Scale property is set and the NumberSequence is not a fixed number |
false |
Rate Number |
Particles emitted every second |
5 |
RateTick Number |
A number from 0 to 1/Rate that ticks up with the time and resets everytime it reaches 1/Rate . |
0 |
Speed NumberRange |
A range of speeds that determine the initial speed of a particle. Pixels/Second |
[30 - 70] |
RotationSpeed NumberRange |
A range of rotation speeds in full rotations every second |
0 |
Rotation NumberRange |
A range of starting rotations of a particle. |
0 |
Lifetime NumberRange |
A range of lifetimes in seconds which determine the time the particle will last. |
[5 - 10] |
SpreadAngle NumberRange |
A range of angles in degrees that the particle's initial velocity direction will be. |
0 |
EmitShape 'area' or 'point' |
If the EmitShape is 'area' then the emitter will emit throughout the emitter, if it is 'point' then it will emit at the TemplateParticle's position |
'point' |
Acceleration Vector2 |
The acceleration, in pixels/second^2, every particle will have. |
[0, 0] |
Drag Number |
The time it takes for a particle to reach half its velocity. |
0 |
Scale NumberSequence |
The way the scale will change over a particle's lifetime. |
NumberSequence.new(1, 1) |
Methods
Note
Most methods are chainable.
SetEmitterParticle
self ParticleEmiter:SetEmitterParticle( GuiObject: GuiObject ) |
Sets the GUI object as the template particle. Property transitions are checked for compatibility and deleted if they are incompatible. All particles will be cleared. |
Examplelocal particleObject = script.Parent.Frame
ParticleEmitter:SetEmitterParticle(particleObject)
SetEmitterRate
self ParticleEmiter:SetEmitterRate( New Rate: Number ) |
Sets the speed particles are emitted at emissions per second. |
ExampleParticleEmitter:SetEmitterRate(15)
SetEmissionShape
ExampleParticleEmitter:SetEmissionShape('Point')
SetSpeed
self ParticleEmiter:SetSpeed( New Speed: Number ) |
Sets the inital speed of a particle. |
self ParticleEmiter:SetSpeed( Minimum Speed: Number , Maximum Speed: Number ) |
Sets the range of speeds that will be the initial speed of a particle. |
ExampleParticleEmitter:SetSpeed(5, 15)
SetRotationSpeed
self ParticleEmiter:SetRotationSpeed( Rotation Speed: Number ) |
Sets the speed particles rotate. Rotations per second. |
self ParticleEmiter:SetRotationSpeed( Minimum Rotation Speed: Number , Maximum Rotation Speed: Number ) |
Sets the range of speeds at which the particles will rotate. |
ExampleParticleEmitter:SetRotationSpeed(.2, .6)
SetRotation
self ParticleEmiter:SetRotation( Rotation: Number ) |
Sets the rotation particles will start at. |
self ParticleEmiter:SetRotation( Minimum Rotation: Number , Maximum Rotation: Number ) |
Sets the range of rotations particles will start at. |
ExampleParticleEmitter:SetRotation(0, 360)
SetLifetime
self ParticleEmiter:SetLifetime( Lifetime: Number ) |
Sets the lifetime which is the amount of time the particles will be active until they get deleted. |
self ParticleEmiter:SetLifetime( Minimum Lifetime: Number , Maximum Lifetime: Number ) |
Sets the range of lifetimes a particle will have. |
ExampleParticleEmitter:SetLifetime(.2, 1)
SetSpreadAngle
self ParticleEmiter:SetSpreadAngle( Spread Angle: Number ) |
Sets the direction of a particle's velocity. |
self ParticleEmiter:SetSpreadAngle( Minimum Spread Angle: Number , Maximum Spread Angle: Number ) |
Sets the range of a particle's velocity direction. |
ExampleParticleEmitter:SetSpreadAngle(75, 105)
SetAcceleration
self ParticleEmiter:SetAcceleration( New Acceleration: Vector2 ) |
self Sets the speed at which the velocity of a particle will change. |
ExampleParticleEmitter:SetAcceleration(Vector2.new())
SetDrag
self ParticleEmiter:SetDrag( Drag: Number ) |
Sets the time that it takes for a particle to reach half of its velocity. |
ExampleParticleEmitter:SetDrag(4)
SetScale
self ParticleEmiter:SetScale( New Scale: NumberSequence ) |
Sets the transition of the particle's size. |
Examplelocal scaleNumberSequence = NumberSequence.new({
NumberSequenceKeypoint.new(0, .5),
NumberSequenceKeypoint.new(1, 1)
})
ParticleEmitter:SetScale(scaleNumberSequence)
SetPropertyTransition
self ParticleEmiter:SetPropertyTransition( Property Name: string , Transition Sequence: NumberSequence or ColorSequence ) |
Sets the transition of one of the particle's property. Property name must exist for the current particle template. |
Examplelocal bgColorSequence = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.fromRGB(100, 50, 85)),
ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 255, 255))
})
ParticleEmitter:SetPropertyTransition('BackgroundColor', bgColorSequence)
GetPropertyTransition
PropertyTransition ParticleEmiter:GetPropertyTransition( Property Name: string ) |
Returns a property transition from the property name given. |
ExampleParticleEmitter:GetPropertyTransition('BackgroundColor')
Emit
self :Emit( Emit Count: Number ) |
Emits the number of particles. |
self :Emit( ) |
Emits a particle. |
ExampleParticleEmitter:Emit(5)
ClearParticles
void :ClearParticles( ) |
Removes every particle |
ExampleParticleEmitter:ClearParticles()
ClearPropertyTransitions
void :ClearPropertyTransitions( ) |
Removes every property transition. |
ExampleParticleEmitter:ClearPropertyTransitions()
Destroy
void :Destroy( ) |
Destroys the particle emitter by destroying all the particles and some other stuff. |
ExampleParticleEmitter:Destroy()
Update
void :Update( Delta Time: Number ) |
Updates every particle's position. Runs for every frame the particle emitter has a particle template. |
ExampleParticleEmitter:Update(10000) -- i don't really know why you would want to do this
Events
Event Name |
Arguments |
Description |
ParticleCreated |
Particle: Particle |
Fired every time a particle is emitted |
ParticleUpdated |
Particle: Particle , DeltaTime: Number , LifetimeProgres: Number |
Fired every frame for every particle on the screen |
Note
Lifetime Progress is a number from 0
to 1
which is the particle's age divided by the particle's determined lifetime
Particle
Properties
Property Name |
Description |
VelocityDirection Vector2 |
The initial direction of the determined velocity. |
Velocity Vector2 |
The current velocity of the particle in pixels. |
Position Vector2 |
The current position of the particle in pixels. |
CurrentAge Number |
The amount of time the particle has been alive. |
DeterminedLifetime Number |
The determined amount of time time until the particle will be destroyed. |
DeterminedRotationSpeed Number |
The determined speed in rotations per second of the particle. |
GuiObject GuiObject |
The particle's gui object. |
EmittedBy ParticleEmitter |
The particle's parent emitter. |
Note
Determined essentially just means its a single random number from a certain range.
Methods
Update
void :Update( Delta Time: Number ) |
Updates the particle's position. Ran every frame for the particle's lifetime. |
ExampleParticle:Update(10000) -- i don't really know why you would do this either
Destroy
void :Destroy( ) |
Destroys the particle, removes it from the Particles table of the emitter, and removes references. Does this automatically on lifetime end. |
ExampleParticle:Destroy()