Search code examples
swiftsprite-kithsvskemitternode

SKEmitterNode HSV range


While I usually prefer RGB color space over HSV, I'd like SKEmitterNode to emit particles with max saturation and value and have hue value to range across all colors. Is that possible?

I'm new to XCode, Swift and SpriteKit, and am unable to open .sks files due to a bug in XCode, so I don't know what can be done that way, but as far as I learned by looking through docs, the closest I can get is setting RGB range as in:

emitter.particleColorRedRange = 0.5;
emitter.particleColorGreenRange = 0.5;
emitter.particleColorBlueRange = 0.5;

Is there something like this:

emitter.particleColorHueRange = 0.5;
emitter.particleColorSaturationRange = 0.0;
emitter.particleColorValueRange = 0.0;

I could make a bunch of SKEmitterNode instances, with each of them having set specific UIColor, but that seems like very inefficient and ugly hack.

Thanks, Mirac7


Solution

  • SKEmitterNode does not provide an API for working within an HSV colorspace. One possible alternative would be to specify an explicit sequence of colors using the particleColorSequence property.