CAEmitterCell emits in two opposite orientation (one is wrong)

468 views Asked by At

I want CAEmitterCell emits in a specific angle. I use emitterCell.emissionLongitude = -CGFloat.pi to specify the orientation angle is -pi(which is left), but it emits to right as well. enter image description here

    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
        }
1

There are 1 answers

0
matt On BEST ANSWER

This is the problem:

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

You are allowing the velocity to range so widely from its original value of 50 that it can be negative. When it is, the cells are emitted in the opposite direction (that is what negative velocity means).