Some particles in the system I set up will just suddenly pop out of existence, instead of gradually fading as I thought they should with the colours I assigned to the system (and most particles do in fact fade out as they should). At first I thought I calculated the buffer size wrong, but changing it didn't fix the problem, and if I actually make it too small, there are just fewer particles emitted. I suspected it might have something to do with the particle life, but my experimentation with it hasn't given me a solution either. I still suspect the problem is in particle life somewhere, as some configurations seem to make the problem better or worse, but I can't get it to go away.
We use Tiled (map editor) maps in the .lua format and Tiled objects to define the properties and position of the particle system.
This is the code where the particle systems are initialised:
Code: Select all
if objects[i].type == "PARTICLE" then
local sprite = love.graphics.newImage("Media/Particles/"..objects[i].properties["image"]);
local mapParticle = love.graphics.newParticleSystem( sprite, tonumber(objects[i].properties["rate"])*tonumber(objects[i].properties["lifeMax"]));
mapParticle:setOffset( sprite:getWidth()/2, sprite:getHeight()/2 );
mapParticle:setLifetime( -1 );
mapParticle:setSpin(math.rad(objects[i].properties["spinMin"]),math.rad(objects[i].properties["spinMax"]), tonumber(objects[i].properties["spinVar"]));
mapParticle:setSpeed(tonumber(objects[i].properties["speedMin"]), tonumber(objects[i].properties["speedMax"]));
mapParticle:setSpread( math.rad(objects[i].properties["spread"]));
mapParticle:setDirection( math.rad(objects[i].properties["direction"]));
mapParticle:setParticleLife( tonumber(objects[i].properties["lifeMin"]), tonumber(objects[i].properties["lifeMax"]));
mapParticle:setRadialAcceleration( tonumber(objects[i].properties["accMin"]), tonumber(objects[i].properties["accMax"]));
mapParticle:setEmissionRate( tonumber(objects[i].properties["rate"]));
mapParticle:setSizes( tonumber(objects[i].properties["size1"]), tonumber(objects[i].properties["size2"]));
mapParticle:setTangentialAcceleration( tonumber(objects[i].properties["tangAccMin"]), tonumber(objects[i].properties["tangAccMax"]));
mapParticle:setColors(255,255,255,0,255,255,255,255,255,255,255,191,255,255,255,127,255,255,255,63,255,255,255,0);
mapParticle:setPosition(objects[i].x, objects[i].y);
table.insert(self.particles, mapParticle);
self.particles[table.getn(self.particles)]:start();
end
Code: Select all
function GameMap:updateParticles(dt)
for i = 1, (table.getn(self.layers[MAP_OBJECT_LAYER].particles)), 1 do
local xOnScreen = self.layers[MAP_OBJECT_LAYER].particles[i]:getX() -self.cam.x;
local yOnScreen = self.layers[MAP_OBJECT_LAYER].particles[i]:getY() -self.cam.y;
if (xOnScreen > -320 and xOnScreen < 748 and yOnScreen > -320 and yOnScreen < 560) then
self.layers[MAP_OBJECT_LAYER].particles[i]:update(dt);
end
end
end
Code: Select all
for i = 1, (table.getn(self.layers[MAP_OBJECT_LAYER].particles)), 1 do
local xOnScreen = self.layers[MAP_OBJECT_LAYER].particles[i]:getX() -self.cam.x;
local yOnScreen = self.layers[MAP_OBJECT_LAYER].particles[i]:getY() -self.cam.y;
if (xOnScreen > -320 and xOnScreen < 748 and yOnScreen > -320 and yOnScreen < 560) then
love.graphics.draw(self.layers[MAP_OBJECT_LAYER].particles[i], -self.cam.x, -self.cam.y );
end
end
Thank you for helping in advance, if additional information is needed, I will provide it.