Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change spritekit particle color

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...

like image 272
Negora Avatar asked Feb 18 '14 06:02

Negora


1 Answers

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];
like image 170
Batalia Avatar answered Sep 22 '22 19:09

Batalia