OrRon / ConfettiView

Confetti View lets you create a magnificent confetti view in your app
MIT License
234 stars 12 forks source link

How to setup only work in Y axis. #4

Closed allenwong closed 7 years ago

allenwong commented 7 years ago

I checked the awesome source code you written, it based on CMMotionManager. I applied the motion confettiView in my project, the entire effect looks good, but how can I stop the X and Z directions, just only work in Y axis.

Thanks in advance.

OrRon commented 7 years ago

Definitely sounds like a setting this view should support I will add an easier way to do it in 0.8 📦 In the meanwhile heres the line you can change to disable this movement: https://github.com/OrRon/ConfettiView/blob/master/ConfettiView/Classes/ConfettiLayer.swift#L103

Change to: self.calculatedVelocity = CGPoint(x: self.baseVelocity.x, y: CGFloat(-accelerometerData.acceleration.y*300 / self.depth))

Cheers, Or.

allenwong commented 7 years ago

@OrRon Thanks a lot! Looking very much forward to see the new 0.8, y: CGFloat(-accelerometerData.acceleration.y*300 / self.depth) It works, but the velocity will be changed when you up and down the phone in vertical direction. Hopefully it can be designed easily to change velocity and switch on and off the x y z axises.