Is there a way to have particles spawn with a random per particle colour based on the current "Color Ramp"? The particles do not change colour over their lifespan, they are simply assigned a colour from somewhere along the "Color Ramp" at birth and keep that colour until they die.
The result of this would be a mix of particles at birth with blend colours from RED through to BLUE.
In my tests I only seem to be able to get the behaviour where particles spawn as RED and then gradually turn to BLUE as the approach the bottom of the screen.
Well, It looks like you can't use a predefined
sks
file for theSKEmitterNode
... I was able to figure this out by programmatically creating theSKEmitterNode
. The reason why is because it doesn't look like when you initiate anSKEmitterNode
with ansks
, it doesn't respond tosetParticleColor:
but programmatically initiating one does.Now today, this past hour, was the first time I ever messed with an SKEmitterNode, so you'll have to bear with me because I couldn't figure out how to get the snow effect perfect, but I'm sure you can just mess with the values an
SKEmitterNode
allows you to change.In any case, I'm going to assume that the
SKEmitterNode
is presented on the SKScene (that's the only way I know how to get your desired effect).First you'll need to make you're
SKEmitterNode
a global/property/etc because you'll need access to it later.In the
MyScene.m
:So what i've done here is programatically created the particle effect, this is where you'll change the animation/speed/etc variables to get the best particle effect you are looking for. I would suggest reading this for more details.
Now remember how I said that it needs to be presented on the SKScene? Well that's because we are going to be taking advantage of the
update:(CFTimeInterval)currentTime
function that comes along with anSKScene
.Inside the
update:(CFTimeInterval)currentTime
is the location where we will be changing theSKEmitterNode
's color. Since this update function is called every frame it makes it easy to change the color without any fancy timers or such. Not sure if this is a good idea, but it's the idea that counts.In this case, we are changing the color to a random RGB value but i'll let you select the colors yourself.
In return this is what my code has produced:
All this said, it doesn't look like you can get the effect you want solely using the particle interface unfortunately.