gpt4 book ai didi

ios - 根据动画方向旋转CAEmitterCell内容

转载 作者:行者123 更新时间:2023-12-01 16:43:25 26 4
gpt4 key购买 nike

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

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

最佳答案

最终在每个方向上使用4个不同的CAEmitterLayers进行叠加,其中每个方向上的generatorPosition是屏幕的每个边缘,而这个端头的大小是generatorSize。

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

关于ios - 根据动画方向旋转CAEmitterCell内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22217225/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com