Ios 有没有办法插入自动画粒子?
我有一个Ios 有没有办法插入自动画粒子?,ios,caemittercell,Ios,Caemittercell,我有一个CAEmitterCell: CAEmitterCell * spriteCell = [CAEmitterCell emitterCell]; spriteCell.contents = (id) [[UIImage imageNamed:@"emitterSprite.png"] CGImage]; NSMutableArray *animatedImagesArray = [NSMutableArray new]; imageView = [[UIImageVi
CAEmitterCell
:
CAEmitterCell * spriteCell = [CAEmitterCell emitterCell];
spriteCell.contents = (id) [[UIImage imageNamed:@"emitterSprite.png"] CGImage];
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];
我希望精灵是动画png序列,而不是单个图像
我所知道的唯一技术是使用UIImageView
:
CAEmitterCell * spriteCell = [CAEmitterCell emitterCell];
spriteCell.contents = (id) [[UIImage imageNamed:@"emitterSprite.png"] CGImage];
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];
NSMutableArray*animatedImagesArray=[NSMutableArray new];
imageView=[[UIImageView alloc]initWithFrame:CGRectMake(…)];
对于(int i=1;i出于操作系统性能的原因,您尝试执行的操作是不可能的。如果您有旋转、缩放、颜色色调等简单变换,则可以在CAEmitterCell的属性中编辑这些值。如果您需要更复杂的动画,则需要使用可处理UIIm的自定义发射器ageViews。但请注意性能影响。我不这么认为。您想要的动画是什么?它是否超出了发射器支持的简单旋转、颜色等功能?是的,标准变换无法再现动画。您知道其他方法吗?您对如何查找/创建动画有何建议“可以处理UIImageView的自定义发射器“?谢谢,这不是我的想法,但也许您可以尝试对CAEmitterCell进行子类化,向其添加UIImageView属性,让CADisplayLink在屏幕刷新时告诉您,然后使用该调用检查UIImageView正在使用的图像,并更新传递正确CGImageRef的内容的值(但仅在图像更改时更新)。希望这有帮助!这是一个想法,但我怀疑某些帧会被跳过?无论如何,如果你感兴趣,我会在可能的情况下就这个问题悬赏。