Question

Is it possible to change the color of a particle after creating in the spritekit editor? I tried setParticleColor but it doesn't appear to do anything. Basically I want to have one particle file and a way to programmatically change the color on the fly...

Was it helpful?

Solution

The particleColor property isn't working because of the color ramp settings in the Particle Editor. These are actually stored in the particleColorSequence, which ignores all other particle color properties.

So, to make it work, you need to override the particleColorSequence setter and make it nil first. Then, you need to set the particleColorBlendFactor to fully blend your chosen color with the particle texture (full blending is 1.0). From then on, any explicit particle color setting should work:

emitter.particleColorSequence = nil;
emitter.particleColorBlendFactor = 1.0;
emitter.particleColor = [SKColor redColor];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top