zoukankan      html  css  js  c++  java
  • CAEmitterLayer 粒子效果(发射器)

    //创建Layer

        CAEmitterLayer *emitterLayer = [CAEmitterLayer layer];

        //边框

        emitterLayer.borderWidth = 1.0f;

        //尺寸

        emitterLayer.frame = CGRectMake(100, 100, 100, 100);

        emitterLayer.masksToBounds = YES;

        

        //发射点

        emitterLayer.emitterPosition = CGPointMake(0, 0);

        //发射模式

        emitterLayer.emitterMode = kCAEmitterLayerOutline;

        //发射形状

        emitterLayer.emitterShape = kCAEmitterLayerCircle;

     

        [self.view.layer addSublayer:emitterLayer];

        

        

        

        //创建粒子

        CAEmitterCell *cell = [CAEmitterCell emitterCell];

        

        //粒子产生率

        cell.birthRate = 2.f;

        //粒子生命周期

        cell.lifetime = 10.f;//

        //粒子速度值

        cell.velocity = 10;

        //速度变化值

        cell.velocityRange = 3.f;//7--13

        //y轴加速度

        cell.yAcceleration = 2.f;

        //发射角度

        cell.emissionRange = 4.0*M_1_PI;

        //粒子颜色

        cell.color = [UIColor blueColor].CGColor;

        //设置图片

        cell.contents = (__bridge id)[UIImage imageNamed:@"snow.png"].CGImage;

        

        emitterLayer.emitterCells = @[cell];

  • 相关阅读:
    统计学基础
    ip地址分类
    OSI七层协议与TCP/IP模型、三次握手与四次挥手
    计算机编码
    [HNOI2008]Cards
    P4309 [TJOI2013]最长上升子序列
    P3794 签到题IV
    P2605 [ZJOI2010]基站选址
    UVA10791
    P3825 [NOI2017]游戏
  • 原文地址:https://www.cnblogs.com/daxueshan/p/6476765.html
Copyright © 2011-2022 走看看