Skip to content

Commit

Permalink
Update init.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldesante committed Jul 17, 2020
1 parent c0b001e commit d2a84f8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ParticleEmitter/init.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
local Particle = require(script.Particle);
local ParticleEmitter = {};

local function spawnParticle(hook, onSpawn)
local particle = Particle.new(game.ReplicatedStorage.Particle:Clone());
local function spawnParticle(hook, particleElement, onSpawn)
local particle = Particle.new(particleElement:Clone());
particle.element.Parent = hook;
onSpawn(particle);
return particle;
end

function ParticleEmitter.new(hook)
function ParticleEmitter.new(hook, particleElement)
local self = {};
self.particles = {};
self.particleElement = particleElement;
self.hook = hook;
self.rate = 5;

Expand All @@ -35,7 +36,7 @@ function ParticleEmitter.new(hook)
given rate can be achieved.
]]
while self.__elapsedTime >= (1/self.rate) do
table.insert(self.particles, spawnParticle(self.hook, self.onSpawn));
table.insert(self.particles, spawnParticle(self.hook, self.particleElement, self.onSpawn));
self.__elapsedTime = self.__elapsedTime - (1/self.rate);
end
end)
Expand Down

1 comment on commit d2a84f8

@joeldesante
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This update allows developers to use there own GUIObjects as particles.

Please sign in to comment.