Group Group Group Group Group Group Group Group Group

How to change the color ramp of an SKEmitterNode?

I am trying to programatically adjust a particleColorSequence of an SKEmitterNode in SpriteKit. I don’t want to replace the entire SKKeyframeSequence, but just alter the color of one of the keyframes. I think the way to do this is to use the setKeyframeValue method, but I cannot work out how to use it. Loading the emitter and trying to change the color like below does not work.

let emitter = SKEmitterNode(fileNamed: "FireWork_Flare_Standard")
emitter?.particleColorSequence?.setKeyframeValue(UIColor.blue, for: 1)

Weirdly, when calling getKeyframeValue, I do see a color is associated with that keyframe, but I can’t seem to change it.

How can I change individual keyframes like this?

@denniswave Do you still have issues with this?

I have created a new color ramp instead, but this was more of a workaround. I never figured out how to change the color ramp created in the scene in code.