【问题标题】:Rotate CAEmitterCell content based on Animation Direction根据动画方向旋转 CAEmitterCell 内容
【发布时间】:2014-03-06 06:52:39
【问题描述】:

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

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

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

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

如何根据单元格移动方向调整内容图像?

【问题讨论】:

    标签: ios calayer caemitterlayer caemittercell


    【解决方案1】:

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

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

    【讨论】:

    • 感谢您分享这个简单的解决方案!我没想到。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多