Independent Particle Colors

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
JJSax
Prole
Posts: 28
Joined: Fri Apr 04, 2014 3:59 am

Independent Particle Colors

Post by JJSax » Sat Oct 26, 2019 11:02 pm

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?

User avatar
Luke100000
Party member
Posts: 231
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

Re: Independent Particle Colors

Post by Luke100000 » Sun Oct 27, 2019 11:50 am

You could use an atlas with several colored stars, then supply the quads with particleSystem:setQuads().

JJSax
Prole
Posts: 28
Joined: Fri Apr 04, 2014 3:59 am

Re: Independent Particle Colors

Post by JJSax » 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.

User avatar
Luke100000
Party member
Posts: 231
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

Re: Independent Particle Colors

Post by Luke100000 » Mon Oct 28, 2019 7:07 am

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.

JJSax
Prole
Posts: 28
Joined: Fri Apr 04, 2014 3:59 am

Re: Independent Particle Colors

Post by JJSax » 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?

User avatar
Luke100000
Party member
Posts: 231
Joined: Mon Jul 22, 2013 9:17 am
Location: Austria
Contact:

Re: Independent Particle Colors

Post by Luke100000 » 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 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.

JJSax
Prole
Posts: 28
Joined: Fri Apr 04, 2014 3:59 am

Re: Independent Particle Colors

Post by JJSax » Mon Oct 28, 2019 8:52 pm

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!

JJSax
Prole
Posts: 28
Joined: Fri Apr 04, 2014 3:59 am

Re: Independent Particle Colors

Post by JJSax » Tue Oct 29, 2019 12:11 am

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)
Attachments
confetti.love
(76.46 KiB) Downloaded 28 times

User avatar
kicknbritt
Citizen
Posts: 59
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

Re: Independent Particle Colors

Post by kicknbritt » 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 )?
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*

JJSax
Prole
Posts: 28
Joined: Fri Apr 04, 2014 3:59 am

Re: Independent Particle Colors

Post by JJSax » Wed Oct 30, 2019 5:59 pm

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?

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 12 guests