Page 1 of 2

Independent Particle Colors

Posted: Sat Oct 26, 2019 11:02 pm
by JJSax
I'm trying to make a confetti particle system. My asset is just a white star and I'm wanting love2d to set the color per confetti star and hold that color throughout it's lifetime.

partycleSystem:setColors sets all particles to said colors/color pattern
and obviously setting the color right before drawing the particle system does the same.
I thought that setting the colors before emitting one would work but it again sets all particles to the same color.

How would I have one particle in the system stay one color?

Re: Independent Particle Colors

Posted: Sun Oct 27, 2019 11:50 am
by Luke100000
You could use an atlas with several colored stars, then supply the quads with particleSystem:setQuads().

Re: Independent Particle Colors

Posted: Sun Oct 27, 2019 11:56 pm
by JJSax
Luke100000 wrote: Sun Oct 27, 2019 11:50 am You could use an atlas with several colored stars, then supply the quads with particleSystem:setQuads().
I could. I was just hoping to have the color be set by love2d. I'd prefer not to make whole new assets if I forget a color or something.

Re: Independent Particle Colors

Posted: Mon Oct 28, 2019 7:07 am
by Luke100000
JJSax wrote: Sun Oct 27, 2019 11:56 pm
Luke100000 wrote: Sun Oct 27, 2019 11:50 am You could use an atlas with several colored stars, then supply the quads with particleSystem:setQuads().
I could. I was just hoping to have the color be set by love2d. I'd prefer not to make whole new assets if I forget a color or something.
Sadly, so far I know there is no setColor function for particle systems. If the particle system is simple you could use a spritebatch instead.

Re: Independent Particle Colors

Posted: Mon Oct 28, 2019 5:19 pm
by JJSax
Luke100000 wrote: Sun Oct 27, 2019 11:50 am Sadly, so far I know there is no setColor function for particle systems. If the particle system is simple you could use a spritebatch instead.
Ah that's a shame. Then I have two options. Would it be more efficient to create a new particle system for every color I want or new sprites?

Re: Independent Particle Colors

Posted: Mon Oct 28, 2019 6:45 pm
by Luke100000
JJSax wrote: Mon Oct 28, 2019 5:19 pm
Luke100000 wrote: Sun Oct 27, 2019 11:50 am Sadly, so far I know there is no setColor function for particle systems. If the particle system is simple you could use a spritebatch instead.
Ah that's a shame. Then I have two options. Would it be more efficient to create a new particle system for every color I want or new sprites?
New sprites. The most expensive part, so far I know, is the draw call itself. Also keep in mind that if you use several systems, the colors are over each other, they don't mix.

Re: Independent Particle Colors

Posted: Mon Oct 28, 2019 8:52 pm
by JJSax
Luke100000 wrote: Mon Oct 28, 2019 6:45 pm New sprites. The most expensive part, so far I know, is the draw call itself. Also keep in mind that if you use several systems, the colors are over each other, they don't mix.
Ok that works then. Thank you for your help!

Re: Independent Particle Colors

Posted: Tue Oct 29, 2019 12:11 am
by JJSax
Luke100000 wrote: Mon Oct 28, 2019 6:45 pm
JJSax wrote: Mon Oct 28, 2019 5:19 pm
Luke100000 wrote: Sun Oct 27, 2019 11:50 am Sadly, so far I know there is no setColor function for particle systems. If the particle system is simple you could use a sprite batch instead.
Ah that's a shame. Then I have two options. Would it be more efficient to create a new particle system for every color I want or new sprites?
New sprites. The most expensive part, so far I know, is the draw call itself. Also keep in mind that if you use several systems, the colors are over each other, they don't mix.
I guess I don't know how to do this. I made a sprite batch, and got the quads. but particlesystem:setQuads(quads) treats it like an animation and iterates through them based off particle lifetime. (see .love attachment)

Re: Independent Particle Colors

Posted: Wed Oct 30, 2019 9:13 am
by kicknbritt
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 )?

Re: Independent Particle Colors

Posted: Wed Oct 30, 2019 5:59 pm
by JJSax
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 )?
You mean something like creating a table of love.graphics.newParticleSystem()? Or do something outside of love2d's particle system entirely?