Fairy lights
This commit is contained in:
@@ -25,6 +25,11 @@ Particle = Entity:New(x,y)
|
||||
y = o.speed * math.sin(o.direction)
|
||||
}
|
||||
|
||||
if particle_data.light ~= nil then
|
||||
o.lightRange = particle_data.light
|
||||
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
|
||||
end
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(particle_data.animation)
|
||||
o:centerOffset(o.body)
|
||||
@@ -41,6 +46,9 @@ Particle = Entity:New(x,y)
|
||||
end
|
||||
|
||||
function Particle:Kill()
|
||||
if self.light ~= nil then
|
||||
KillLight(self.light)
|
||||
end
|
||||
if self.id ~= nil then
|
||||
for _, e in pairs(LoadedParticles) do
|
||||
if e.id > self.id then
|
||||
@@ -56,6 +64,9 @@ function Particle:HandleAnimation()
|
||||
self.body:Animate()
|
||||
self.timer = self.timer + current_dt
|
||||
self.sprite_alpha = (self.time-self.timer)/self.time
|
||||
if self.light ~= nil then
|
||||
self.light.range = self.lightRange * self.sprite_alpha/2
|
||||
end
|
||||
if self.sprite_alpha < 0 then self:Kill() end
|
||||
self:Draw(self.body)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user