1

这就是我的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"];

我需要立即创建所有粒子,以便产生爆炸效果。这是设置的方式,它们只会一一生成。

4

0 回答 0