0

I have a CAEmitterLayer and I'd like to have a simple animation run over the course of each particle's life.

As soon as particle pops in, I'd like it to scale up to about 1.2, then after a short time have it scale back to 1.0 and stay that way until it's lifetime expires.

I know about the scale, scaleRange and scaleSpeed properties of the CAEmitterCell but they're way too random for what I need.

Is this possible to do? I've tried adding a CABasicAnimation like this (my CAEmitterCell's name is "heart"):

CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"emitterCells.heart.scale"];
anim.fromValue = @(1.0);
anim.toValue = @(2.0);
anim.duration = 3.0;
anim.fillMode = kCAFillModeForwards;
anim.repeatCount = CGFLOAT_MAX;
[self.heartsEmitter addAnimation:anim forKey:@"scaleAnimation"];

but it doesn't work, the particles just appear at a random scale, they don't animate at all.

drix
  • 21
  • 3

1 Answers1

0

I'm not completely sure, but it seems to me that you are applying the animation to the emitter instead of the cells.

If the CAEmitterCell's name is heart try this: [self.heart addAnimation:anim forKey:@"scaleAnimation"];. Does this help?

RoberRM
  • 883
  • 9
  • 18