0

我希望 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
        }
4

1 回答 1

1

这就是问题:

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

您允许速度与原始值 50 相差很大,以至于它可能是负数。当它是时,细胞以相反的方向发射(这就是负速度的意思)。

于 2017-12-11T01:45:26.780 回答