用CAEmitterLayer实现粒子动画飘雪花效果
2015-03-24 23:02
495 查看
// Configure the particle emitter to the top edge of the screen
CAEmitterLayer *snowEmitter = [CAEmitterLayer
layer];
snowEmitter.emitterPosition =
CGPointMake(self.view.bounds.size.width
/ 2.0, -30);
snowEmitter.emitterSize
= CGSizeMake(self.view.bounds.size.width
* 2.0, 0.0);;
// Spawn points for the flakes are within on the outline of the line
snowEmitter.emitterMode
= kCAEmitterLayerOutline;
snowEmitter.emitterShape
= kCAEmitterLayerLine;
// Configure the snowflake emitter cell
CAEmitterCell *snowflake = [CAEmitterCell
emitterCell];
snowflake.birthRate
= 10.0;//粒子产生速率
snowflake.lifetime
= 120.0;//粒子的生命时间
snowflake.velocity
= -300;
//粒子发射速度 // falling down slowly
snowflake.velocityRange =
5;
snowflake.yAcceleration =
2;
snowflake.emissionRange =
0.5 *
M_PI;
// some variation in angle
snowflake.spinRange
= 0.25 * M_PI;
// slow spin
snowflake.contents
= (id) [[UIImage
imageNamed:@"DazFlake"]
CGImage];
snowflake.color
= [[UIColor
colorWithRed:0.600
green:0.658
blue:0.743
alpha:1.000]
CGColor];
// Make the flakes seem inset in the background
snowEmitter.shadowOpacity =
1.0;
snowEmitter.shadowRadius =
0.0;
snowEmitter.shadowOffset =
CGSizeMake(0.0,
1.0);
snowEmitter.shadowColor = [[UIColor
whiteColor] CGColor];
// Add everything to our backing layer below the UIContol defined in the storyboard
snowEmitter.emitterCells = [NSArray
arrayWithObject:snowflake];
[self.view.layer
insertSublayer:snowEmitter atIndex:0];
CAEmitterLayer *snowEmitter = [CAEmitterLayer
layer];
snowEmitter.emitterPosition =
CGPointMake(self.view.bounds.size.width
/ 2.0, -30);
snowEmitter.emitterSize
= CGSizeMake(self.view.bounds.size.width
* 2.0, 0.0);;
// Spawn points for the flakes are within on the outline of the line
snowEmitter.emitterMode
= kCAEmitterLayerOutline;
snowEmitter.emitterShape
= kCAEmitterLayerLine;
// Configure the snowflake emitter cell
CAEmitterCell *snowflake = [CAEmitterCell
emitterCell];
snowflake.birthRate
= 10.0;//粒子产生速率
snowflake.lifetime
= 120.0;//粒子的生命时间
snowflake.velocity
= -300;
//粒子发射速度 // falling down slowly
snowflake.velocityRange =
5;
snowflake.yAcceleration =
2;
snowflake.emissionRange =
0.5 *
M_PI;
// some variation in angle
snowflake.spinRange
= 0.25 * M_PI;
// slow spin
snowflake.contents
= (id) [[UIImage
imageNamed:@"DazFlake"]
CGImage];
snowflake.color
= [[UIColor
colorWithRed:0.600
green:0.658
blue:0.743
alpha:1.000]
CGColor];
// Make the flakes seem inset in the background
snowEmitter.shadowOpacity =
1.0;
snowEmitter.shadowRadius =
0.0;
snowEmitter.shadowOffset =
CGSizeMake(0.0,
1.0);
snowEmitter.shadowColor = [[UIColor
whiteColor] CGColor];
// Add everything to our backing layer below the UIContol defined in the storyboard
snowEmitter.emitterCells = [NSArray
arrayWithObject:snowflake];
[self.view.layer
insertSublayer:snowEmitter atIndex:0];
相关文章推荐
- iOS CAEmitterLayer实现粒子发射动画效果
- iOS CAEmitterLayer 实现粒子发射动画效果
- iOS CAEmitterLayer简介,基于CAEmitterLayer实现粒子效果 —— HERO博客
- swift 实现漂亮的粒子效果CAEmitterLayer
- iOS CAEmitterLayer 实现粒子效果
- 使用Layer类和Sprite类实现手机游戏的动画效果
- 【iOS开发-24】导航控制器下不同视图控制器之间切换:利用CATrasition和view的layer层来实现自定义的动画效果
- CATextLayer与CAGradientLayer实现文字渐变的动画效果
- Unity3D中暂停时的动画及粒子效果实现
- ios 基于CAEmitterLayer的雪花,烟花,火焰,爱心等效果demo(转)
- IOS 粒子发射器,雪花落下、创建火焰、河流、蒸汽的动画效果源代码
- Android动画-实现雪花飞舞动画效果
- 使用animator实现粒子动画效果
- ios 基于CAEmitterLayer的雪花,烟花,火焰,爱心等效果demo
- iOS CAReplicatorLayer实现脉冲动画效果
- IOS动画效果源代码整理(粒子、雪花、火焰、河流、蒸汽)
- CAReplicatorLayer复制Layer和动画, 实现神奇的效果
- ios粒子效果CAEmitteCell CAEmitterLayer
- Unity3D中暂停时的动画及粒子效果实现
- 利用layer的mask属性实现逐渐揭示的动画效果,layermask