6

I have an app where the user can edit an emitter node and take a screenshot to the photo library. In the settings where they can change stuff like the birthrate, angle, ect. I allow them to change the color of the emitter node.

I am using:

node.particleColor = [SKColor redColor];

and it isn't changing the color of the particles.

However when I added NSLog statements to it and asked it what node.particleColor was it returned 1 0 0 1, which is what I was expecting but the node never changes color.

Any ideas as to what I can do to change its color?

user3473834
  • 103
  • 1
  • 5
  • Please can someone explain to me what this has to do with the `xcode IDE`?????? – Popeye Mar 28 '14 at 18:38
  • The answer for this can be found here: http://stackoverflow.com/a/19818606/2043580 – ZeMoon Jul 30 '14 at 11:27
  • possible duplicate of [Specify random particle start colour with no animated change?](http://stackoverflow.com/questions/19813252/specify-random-particle-start-colour-with-no-animated-change) – ZeMoon Jul 30 '14 at 11:27

2 Answers2

11

Hey i think i just figured out this problem. Not sure if your code is different however.

For me i have a SKEmitterNode created like this

SKEmitterNode *explosion = [NSKeyedUnarchiver
                                        unarchiveObjectWithFile:[[NSBundle mainBundle]
                                        pathForResource:@"Explosion" ofType:@"sks"]];

then to change its color i do this

explosion.particleColor = [SKColor redColor];

then in i set the blend factor to 1

explosion.particleColorBlendFactor = 1.0;

and finally i turn the color sequence to nil (this was the tricky part)

explosion.particleColorSequence = nil;

By turning the color sequence to nil, it no longer ignores the particle color. Not sure why it initially wasn't set to nil like the reference says, but this is what fixed it for me. Hope this helps!

Chris Brasino
  • 296
  • 2
  • 14
1

You have to set the colorBlendFactor as well to blend the set color with the particle texture:

node.colorBlendFactor = 1.0;
CodeSmile
  • 64,284
  • 20
  • 132
  • 217