我正在努力使我的 CAEmitterLayer 对象一次只生成一个单元格。一旦细胞寿命到期,我想产生下一个,依此类推。这样做的原因是因为它们不断重叠导致它看起来很糟糕。
我尝试了苹果文档,但找不到任何有用的东西。 https://developer.apple.com/documentation/quartzcore/caemitterlayer
func setUpEmitter(){
let emitter = CAEmitterLayer()
emitter.emitterPosition = CGPoint(x: view.frame.width / 2, y: 0)
emitter.emitterSize = CGSize(width: view.frame.width, height: 2)
emitter.emitterShape = CAEmitterLayerEmitterShape.line
emitter.emitterCells = generateEmitterCells()
view.layer.insertSublayer(emitter, at: 0)
// TutorialView.layer.addSublayer(emitter)
}
func generateEmitterCells() -> [CAEmitterCell]{
var cells = [CAEmitterCell]()
let cell = CAEmitterCell()
cell.contents = UIImage(named: "startVCversion3")!.cgImage
cell.birthRate = 0.2
cell.lifetime = 100
cell.velocity = CGFloat(55)
cell.emissionLongitude = (180 * (.pi/180))
cell.emissionRange = (45 * (.pi/180))
cell.scale = 1
cell.scaleRange = 1
cells.append(cell)
return cells
}