I am looking for the same effect as we have in SpriteKit
for the emitter particles, the scale
effect that can make a particle image bigger or smaller depending on the time. (a simple red circle for example, getting bigger and disappearing after 1 second.) I cannot find the same scale
option as we can find in SpriteKit
. The image can be bigger and stay bigger, but it would not change depending on the time then.
Would someone know a good way to do this?
Thanks
EDIT:
None of these attempts worked, would you know why?
func addParticleSceneKit(){
println("add")
var fire = SCNParticleSystem(named: "circle1.scnp", inDirectory: "art.scnassets/Particles")
fire.particleSize = 5
emitter.addParticleSystem(fire) //emitter is a SCNNode
/*
let bigger = SCNAction.runBlock { (node) -> Void in
dispatch_async(dispatch_get_main_queue(), { () -> Void in
SCNTransaction.setAnimationDuration(1)
fire.propertyControllers = [SCNParticlePropertySize : 10.0]
})
}
emitter.runAction(bigger)
*/
//SCNTransaction.begin()
//SCNTransaction.setAnimationDuration(1)
//fire.propertyControllers = [SCNParticlePropertySize : 10.0]
//SCNTransaction.commit()
}
Wow. Just wow. You've thrown a lot of code at the wall just to see what sticks, but have you looked in the documentation?
The method description for SCNParticlePropertyController
's initializer includes a code example that does almost exactly what you're asking for — it animates particle sizes. Reproduced here:
// 1. Create and configure an animation object.
let animation = CAKeyframeAnimation()
animation.values = [ 0.1, 1.0, 3.0, 0.5 ]
// 2. Create a property controller from the animation object.
let sizeController = SCNParticlePropertyController(animation: animation)
// 3. Assign the controller to a particle system, associating it with a particle property.
particleSystem.propertyControllers = [ SCNParticlePropertySize: sizeController ]
If you only need a from size and a to size instead of keyframes, you can use a CABasicAnimation
in step 1.