使用CAEmitterLayer和单元格显示具有方向敏感内容图像的粒子(箭头)。
希望内容(箭头图像)指向单元格移动的方向。
下面是让所有箭头从外部边缘向中心移动的代码。如何旋转图像,使图像指向移动方向:
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];如何根据细胞移动的方向调整内容图像?
发布于 2014-03-07 14:28:45
最终使用了4个不同的CAEmitterLayers,每个方向一个,其中emitterPosition是屏幕的每个边缘,emitterSize是给定边缘的长度。
如果有更好的解决方案,请分享。
https://stackoverflow.com/questions/22217225
复制相似问题