美文网首页
撒金币-粒子效果

撒金币-粒子效果

作者: 齐云霄霄 | 来源:发表于2018-08-16 10:25 被阅读13次
效果图

话不多说,项目改版,旧的功能需要移除,拆分出来记录一下以便需要时回顾。

https://github.com/tyjlp/throwingCoin_CAEmitterLayer.git


-(void)startAnimationWithLayer:(CALayer*)superLayer{

   //初始化粒子发射器

    [self initEmitterLayerWithSuperLayer:superLayer];

    CABasicAnimation * effectAnimation = [CABasicAnimation animationWithKeyPath:@"emitterCells.zanShape.birthRate"];

    effectAnimation.fromValue= [NSNumbernumberWithFloat:30];

    effectAnimation.toValue= [NSNumbernumberWithFloat:0];

    effectAnimation.duration=2.0f;

    effectAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

    effectAnimation.delegate=self;

    [self.emitterLayeraddAnimation:effectAnimationforKey:@"zanCount"];

    //

    [self playSoundWithSoundName:@"签到金币音效.mp3"];

}

-(void)initEmitterLayerWithSuperLayer:(CALayer*)superLayer{

    //发射源

    CAEmitterLayer * emitter = [CAEmitterLayer layer];

    emitter.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);

    [superLayeraddSublayer:self.emitterLayer= emitter];

    //发射源形状

    emitter.emitterShape = kCAEmitterLayerCircle;

    //发射模式

    emitter.emitterMode = kCAEmitterLayerOutline;

    //渲染模式

    //    emitter.renderMode = kCAEmitterLayerAdditive;

    //发射位置

    emitter.emitterPosition = CGPointMake(emitter.frame.size.width/2, emitter.frame.size.height/2);

    //发射源尺寸大小

    emitter.emitterSize=CGSizeMake(20,20);

    // 从发射源射出的粒子

    CAEmitterCell * cell = [CAEmitterCell emitterCell];

    cell.name=@"zanShape";

    //粒子要展现的图片

    cell.contents= (__bridgeid)[UIImageimageNamed:@"coin"].CGImage;

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

    //            cell.contentsRect = CGRectMake(100, 100, 100, 100);

    //粒子透明度在生命周期内的改变速度

    cell.alphaSpeed= -0.5;

    //生命周期

    cell.lifetime=3.0;

    //粒子产生系数(粒子的速度乘数因子)

    cell.birthRate=0;

    //粒子速度

    cell.velocity=300;

    //速度范围

    cell.velocityRange = 100;

    //周围发射角度

    cell.emissionRange=M_PI/8;

    //发射的z轴方向的角度

    cell.emissionLatitude = -M_PI;

    //x-y平面的发射方向

    cell.emissionLongitude = -M_PI / 2;

    //粒子y方向的加速度分量

    cell.yAcceleration = 250;

    emitter.emitterCells=@[cell];

}

相关文章

  • 撒金币-粒子效果

    话不多说,项目改版,旧的功能需要移除,拆分出来记录一下以便需要时回顾。 https://github.com/ty...

  • iOS 高仿飞聊红包动画 散射动画 lottie动画、CAEmi

    效果图如下 原理 动画主要分为几部分 散射粒子动画 (CAEmitterLayer + 金币图画) 循环滚动的RM...

  • 摇一摇撒金币效果

    公司要做个活动,然后要做撒金币效果,网上找了好多资料效果不是很好,这个是网上找的一个比较满意的效果把代码分享出来,...

  • IOS emitter粒子发射实现撒花效果

    https://github.com/soh1314/QS_EmitterView 下载完后觉得好的可以微信支持一...

  • 粒子效果

    特效组件(靠材质体现): component-effect 拖尾效果: 镜头光晕(Lens Flars):涉及到后...

  • 粒子效果

    //获取元素 var canvas = document.getElementById('canvas'); va...

  • 粒子效果

    粒子效果(复制层) 开始 重绘 自定义一个DrawView绑定控制器的viewawakeFromNib中添加手势p...

  • 粒子效果

    粒子效果 说到粒子效果,iPhone用户应该经常见到的,比如下雨天时天气app中的雨滴效果。还有和小伙聊微信时不小...

  • iOS --粒子效果简单实现

    前言 :整个粒子动画效果,学习学习... 看看演示效果 Pragma mark — NO.1 创建最简单的粒子效果...

  • 音视频开发之旅(15) OpenGL ES粒子系统 - 喷泉

    目录 粒子和粒子系统 实践:喷泉效果 遇到的问题 资料 收获 通过该篇的实践实现如下效果 一、什么是粒子和粒子系统...

网友评论

      本文标题:撒金币-粒子效果

      本文链接:https://www.haomeiwen.com/subject/ojdnbftx.html