Core Animation - 爆炸效果

简介: Core Animation - 爆炸效果

CAEmitterLayer是一个例子引擎,我们可以把它比作一个太阳,它向四面八方辐射粒子,然后我们用上图片和它的一些设置就做出来了爆炸效果,详细的设置见代码和注释:

 CAEmitterLayer *emitter = [CAEmitterLayer layer];
    emitter.frame = self.view.bounds;
    [self.view.layer addSublayer:emitter];
    //configure emitter    kCAEmitterLayerAdditive合并重叠部位的亮度,使之更亮
    emitter.renderMode = kCAEmitterLayerAdditive;
    emitter.emitterPosition = CGPointMake(emitter.frame.size.width / 2.0, emitter.frame.size.height / 2.0);
    //create a particle template
    CAEmitterCell *cell = [[CAEmitterCell alloc] init];
    cell.contents = (__bridge id)[UIImage imageNamed:@"fire.png"].CGImage;
    //加速或者扩大整个粒子系统
    cell.birthRate = 150;
    //存在时间
    cell.lifetime = 5.0;
    //混合图片内容颜色的混合色(重叠部分颜色)
    cell.color = [UIColor colorWithRed:0.98f green:0.54f blue:0.14f alpha:1.00f].CGColor;
    //每秒钟透明度变化,逐渐消失
    cell.alphaSpeed = -0.4;
    //控制粒子辐射的速度
    cell.velocity = 100;
    //粒子辐射速度的范围,像是一个最大速度
    cell.velocityRange = 100;
    //辐射角度,如果小于360度就是一个扇形区域
    cell.emissionRange = M_PI * 2.0;
    //add particle template to emitter
    emitter.emitterCells = @[cell];

github下载地址:https://github.com/codeliu6572/CAEmitterLayer-

目录
相关文章
|
算法 iOS开发
Core Animation - 视觉效果<三>
Core Animation - 视觉效果<三>
49 0
|
iOS开发
Core Animation - 视觉效果<一>
Core Animation - 视觉效果<一>
74 0
Core Animation - 视觉效果<二>
Core Animation - 视觉效果<二>
32 0
Core Animation - 变换<一>
Core Animation - 变换<一>
64 0
Core Animation - 变换<一>
Core Animation - 变换<三>
Core Animation - 变换<三>
27 0
Core Animation - 变换<三>
Core Animation - 变换<二>
Core Animation - 变换<二>
60 0
Core Animation - 变换<五>
Core Animation - 变换<五>
46 0
Core Animation - 变换<四>
Core Animation - 变换<四>
63 0
Core Animation - 变换<四>
Core Animation - 如何来绘制一个火柴人
Core Animation - 如何来绘制一个火柴人
90 0
Core Animation - 如何来绘制一个火柴人
|
图形学
Core Animation -关键帧动画
Core Animation -关键帧动画
82 0