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...
Asked
Active
Viewed 4,498 times
1 Answers
46
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];

Batalia
- 2,425
- 1
- 17
- 18
-
The colour of the image used for the particle greatly affects the result of the particle colouring. Using a white image results in the brightest colours, using eg. a red image means only the red channel is coloured, and so on. – Johan Mar 07 '21 at 11:20