fixed all entities instanced an entity when grabbing functions from parent Entity. now it just sets metatable
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
LoadedObjects.Particles = {}
|
||||
|
||||
Particle = Entity:new()
|
||||
Particle = {}
|
||||
Particle.type = "Particle"
|
||||
Particle.supertype = Entity.type
|
||||
Particle.display = Animation:new(animation.particle.simple)
|
||||
setmetatable(Particle, Entity)
|
||||
|
||||
function Particle:new(x,y,particle_data)
|
||||
local o = Entity:new(x,y)
|
||||
@@ -10,17 +11,18 @@ function Particle:new(x,y,particle_data)
|
||||
o.pos = {x = x, y = y}
|
||||
|
||||
o.speed = particle_data.speed or 0
|
||||
o.direction = particle_data.direction or o.direction
|
||||
o.sprite_rotation = particle_data.sprite_rotation or o.sprite_rotation
|
||||
o.sprite_offset = particle_data.sprite_offset or o.sprite_offset
|
||||
o.sprite_scale = particle_data.sprite_scale or o.sprite_scale
|
||||
o.sprite_tint = particle_data.sprite_tint or o.sprite_tint
|
||||
o.sprite_alpha = particle_data.sprite_alpha or o.sprite_alpha
|
||||
o.direction = particle_data.direction or 0
|
||||
o.sprite_rotation = particle_data.sprite_rotation or 0
|
||||
o.sprite_offset = particle_data.sprite_offset or vector(0,0)
|
||||
o.sprite_scale = particle_data.sprite_scale or vector(1,1)
|
||||
o.sprite_tint = particle_data.sprite_tint or {1,1,1}
|
||||
o.sprite_alpha = particle_data.sprite_alpha or 1
|
||||
o.sprite_alpha_fade = particle_data.sprite_alpha_fade or false
|
||||
o.sprite_alpha_base = o.sprite_alpha
|
||||
o.sprite_flip = particle_data.sprite_flip or o.sprite_flip
|
||||
|
||||
o.sprite_flip = particle_data.sprite_flip or vector(1,1)
|
||||
o.func = particle_data.func or nil
|
||||
o.time = particle_data.time or nil
|
||||
|
||||
if o.time ~= nil then
|
||||
if particle_data.time_unit ~= nil
|
||||
and particle_data.time_unit == "frames" then
|
||||
@@ -36,13 +38,13 @@ function Particle:new(x,y,particle_data)
|
||||
y = o.speed * math.sin(o.direction)
|
||||
}
|
||||
|
||||
o.speed_increase = particle_data.speed_increase or 0
|
||||
|
||||
if particle_data.light ~= nil then
|
||||
o.light_range = particle_data.light
|
||||
local flicker = particle_data.light_flicker or nil
|
||||
local color = particle_data.light_color or nil
|
||||
o.light = Light:new(o.pos.x,o.pos.y,o.light_range,flicker,color)
|
||||
local light_data = {}
|
||||
light_data.radius = particle_data.light
|
||||
light_data.shine_radius = particle_data.light_shine or nil
|
||||
light_data.flicker = particle_data.light_flicer or nil
|
||||
light_data.color = particle_data.light_color or nil
|
||||
o.light = Light:new(o.pos.x,o.pos.y,light_data)
|
||||
end
|
||||
|
||||
-- animations
|
||||
@@ -90,14 +92,11 @@ function Particle:handleAnimation()
|
||||
end
|
||||
|
||||
function Particle:doLogic()
|
||||
-- adjust speed
|
||||
if self.speed_increase ~= 0 then
|
||||
self.speed = self.speed + self.speed_increase
|
||||
self.vel.x = self.speed * math.cos(self.direction)
|
||||
self.vel.y = self.speed * math.sin(self.direction)
|
||||
if self.func then
|
||||
self:func()
|
||||
end
|
||||
|
||||
if self.time ~= nil then
|
||||
if self.time then
|
||||
if self.timer >= self.time then self:kill() end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user