CAEmitterCell 以两个相反的方向发射(一个是错误的)

CAEmitterCell emits in two opposite orientation (one is wrong)

我希望 CAEmitterCell 以特定角度发射。我使用 emitterCell.emissionLongitude = -CGFloat.pi 指定方向角为 -pi(左侧),但它也向右发射。

    func setUpEmitterCell() {
            emitterCell.contents = UIImage(named: "spark_small")?.cgImage

            emitterCell.velocity = 50.0
            emitterCell.velocityRange = 500.0


            let zeroDegreesInRadians = degreesToRadians(0.0)
            emitterCell.spin = degreesToRadians(130.0)
            emitterCell.spinRange = zeroDegreesInRadians
            emitterCell.emissionRange = degreesToRadians(10.0)
            emitterCell.emissionLongitude = -CGFloat.pi

            emitterCell.lifetime = 1.0
            emitterCell.birthRate = 1000.0
            emitterCell.xAcceleration = 0.0
            emitterCell.yAcceleration = 0.0
        }

这是问题所在:

        emitterCell.velocity = 50.0
        // but then:
        emitterCell.velocityRange = 500.0

您允许速度从其原始值 50 的变化范围如此之大,以至于它可能为负数。当它是时,细胞以相反的方向发射(这就是负速度的意思)。