Sorry, I really thought setQuads would use them randomly, not with the lifetime.JJSax wrote: ↑Wed Oct 30, 2019 5:59 pmYou mean something like creating a table of love.graphics.newParticleSystem()? Or do something outside of love2d's particle system entirely?kicknbritt wrote: ↑Wed Oct 30, 2019 9:13 am Why dont you just make a table that holds all the confetti particles, update all of them for things like movement of the confetti particles and then draw all of them using a SpriteBatch, setting thier individual colors with SpriteBatch:setColor( r, g, b, a )?
And kicknbritt also means the alternative I wrote above, so it might be the best solution: don't use the inbuilt particle system, make one yourself.
Here is one, rather basic and not optimized.
Code: Select all
particles = { }
spritebatch = love.graphics.newSpriteBatch(yourSprite, 256, "dynamic")
function newParticle(x, y)
table.insert(particles, {
color = {math.random(), math.random(), math.random()},
x = x,
y = y,
ax = math.random()-0.5,
ay = math.random()-0.5,
rot = math.random()*math.pi*2,
lifetime = math.random()+1.0,
})
end
function drawParticles()
spritebatch:clear()
for d,s in ipairs(particles) do
spritebatch:setColor(s.color)
spritebatch:add(s.x, s.y, s.rot, 1.0, 1.0, yourSprite:getWidth()/2, yourSprite:getHeight()/2)
end
love.graphics.draw(spritebatch)
end
function updateParticles(dt)
--note the reversed order to avoid errors when using table.remove
for i = #particles, 1, -1 do
local p = particles[i]
p.x = p.x + p.ax * dt
p.y = p.y + p.ay * dt
p.ay = p.ay + dt
p.lifetime = p.lifetime - dt
if p.lifetime < 0 then
table.remove(particles, i)
end
end
end