这就是我的emitterLayer的设置方式:
emitterLayer.position = CGPointMake(sumIndent
,_emitterView.frame.origin.y);
emitterLayer.backgroundColor = [[UIColor clearColor] CGColor];
emitterLayer.emitterPosition = CGPointZero;
emitterLayer.emitterSize = CGSizeMake(100, 100);
emitterLayer.emitterShape = kCAEmitterLayerBackToFront;
[_emitterView.layer addSublayer:emitterLayer];
这就是我的emitterCell的设置方式:
CAEmitterCell * coinCell = [CAEmitterCell emitterCell];
coinCell.name = @"coins";
coinCell.contents = (id) [[UIImage imageNamed:@"smallCoin.png"] CGImage];
coinCell.birthRate = 0;
coinCell.lifetime = 0.3;
coinCell.lifetimeRange = 1.1;
coinCell.velocity = 900;
coinCell.emissionRange = 2 * M_PI;
coinCell.spin = 0.0;
coinCell.spinRange = 7 * M_PI;
coinCell.scale = 1.85;
coinCell.alphaSpeed=-1.0/coinCell.lifetime;
这就是我开始/停止动画的方式:
[emitterLayer setValue:[NSNumber numberWithInt:PARTICLE_INTENSITY] forKeyPath:@"emitterCells.coins.birthRate"];
[emitterLayer setValue:[NSNumber numberWithInt:0] forKeyPath:@"emitterCells.coins.birthRate"];
我需要立即创建所有粒子,以便我可以产生爆炸效果。它的设置方式只能逐个产生。