ioscaemittercell

CAEmitter any way to insert self-animated particles?


I have a CAEmitterCell :

CAEmitterCell * spriteCell = [CAEmitterCell emitterCell];  
spriteCell.contents = (id) [[UIImage imageNamed:@"emitterSprite.png"] CGImage];

I would like the sprite to be an animated png sequence (or so) instead of a single image.

The only technique I know makes use of an UIImageView :

   NSMutableArray *animatedImagesArray = [NSMutableArray new];
    imageView = [[UIImageView alloc] initWithFrame:CGRectMake(...)];
    for (int i = 1; i <= 10; i++)
    {[animatedImagesArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"sequenceNo-%d%@", i, @".png"]]];}
    imageView.animationImages = animatedImagesArray;
    [view addSubview:imageView];

CAEmitterCell.contents doesn't seem to accept UIImageView. Is there a way to achieve this ?


Solution

  • For reasons of performance in the operating system what you are trying to do is not possible. If you have simple transformations like rotation, scale, colour tint you can edit those values in the properties of your the CAEmitterCell. If you require a more complex animation you will need to use a custom emitter that can handle UIImageViews. But be mindful of the performance implications.