0

Using SKEmitterNode in SprikeKit, is it possible to change the speed/alpha of particles after they are released?

What I'm looking for is a particle emitter that emits particles, those particles are static but after x amount of seconds, they start moving. Is this possible?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
0xSina
  • 20,973
  • 34
  • 136
  • 253
  • My solution to alter speed of already cerated particles: https://stackoverflow.com/questions/21839325/skemitternode-change-particle-speed-to-particles-already-emitted/67045466#67045466 – Sergey Apr 11 '21 at 13:24

1 Answers1

0

I wrote the answer in swift before i saw the objective-c tag.. hope thats okay.

heres my particle file so you can try it yourself: DOWNLOAD

let emitter = SKEmitterNode(fileNamed: "fire")
emitter.position = CGPoint(x: self.size.width/2, y: self.size.height/2)

let time = CGFloat(2)
emitter.runAction(SKAction.sequence([
    SKAction.waitForDuration(3),
    SKAction.customActionWithDuration(NSTimeInterval(time), actionBlock: {
        _, t in
        let timePercentage = t / time  // percentage of elapsed time
        let maxSpeed = CGFloat(200)
        emitter.particleSpeed = timePercentage * maxSpeed
    })

]))

self.addChild(emitter)

this code will allow you to animate your emitter's properties over time.

hamobi
  • 7,940
  • 4
  • 35
  • 64
  • 1
    Thanks but this doesn't modify the particles that have ALREADY been emitted. – 0xSina Jan 27 '15 at 08:16
  • I found out the answer. I need to use alphaSequence and scaleSequence : http://stackoverflow.com/questions/27476390/spritekit-trouble-with-particle-keyframe-sequence – 0xSina Jan 27 '15 at 08:20
  • it was your question (link above) whose's answer helped me out so thank you anyways! – 0xSina Jan 27 '15 at 09:15