首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于动画方向旋转CAEmitterCell内容

基于动画方向旋转CAEmitterCell内容
EN

Stack Overflow用户
提问于 2014-03-06 14:52:39
回答 1查看 678关注 0票数 2

使用CAEmitterLayer和单元格显示具有方向敏感内容图像的粒子(箭头)。

希望内容(箭头图像)指向单元格移动的方向。

下面是让所有箭头从外部边缘向中心移动的代码。如何旋转图像,使图像指向移动方向:

代码语言:javascript
复制
emitterLayer = [CAEmitterLayer layer];
emitterLayer.emitterPosition = self.view.center;
emitterLayer.emitterSize = self.view.bounds.size;
emitterLayer.emitterMode = kCAEmitterLayerOutline;
emitterLayer.emitterShape = kCAEmitterLayerRectangle;

CAEmitterCell* arrow = [CAEmitterCell emitterCell];
arrow.birthRate     = 10;
arrow.velocity      = 100;
arrow.emissionLatitude = M_PI;
arrow.scale         = 0.5;
arrow.lifetime      = 2;
arrow.contents = (id) [[UIImage imageNamed:@"arrowOutline.png"] CGImage];


emitterLayer.emitterCells = @[arrow];
[self.view.layer addSublayer:emitterLayer];

如何根据细胞移动的方向调整内容图像?

EN

回答 1

Stack Overflow用户

发布于 2014-03-07 14:28:45

最终使用了4个不同的CAEmitterLayers,每个方向一个,其中emitterPosition是屏幕的每个边缘,emitterSize是给定边缘的长度。

如果有更好的解决方案,请分享。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22217225

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档