2014-03-06 32 views
1

使用CAEmitterLayer和Cell显示具有方向敏感内容图像的粒子(箭头)。根据动画方向旋转CAEmitterCell内容

想要内容(箭头图像)指向细胞移动的方向。

这里是让所有箭头从外边缘向中心移动的代码。如何在运动的方向旋转图像,图像点:

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]; 

如何获得内容画面调整为基础,以对细胞运动的方向是什么?

回答

0

使用4个不同的CAEmitterLayers结束每个方向,其中emitterPosition是屏幕的每个边,emitterSize是给定边的长度。

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