if currentPoint.x <= imageWidth /
2 { currentPoint.x = imageWidth /
2 ballXVelocity = -
ballXVelocity *
0.
8 }
if currentPoint.x >=
bounds.size.width - imageWidth /
2 { currentPoint.x =
bounds.size.width - imageWidth /
2 ballXVelocity = -
ballXVelocity *
0.
8 }
3.2.2 开启陀螺仪并更新
manager.deviceMotionUpdateInterval = 1 / 60 manager.startDeviceMotionUpdates(to: OperationQueue.main) { (motion, error) in self.ballView!.accelleration = (motion?.gravity)! DispatchQueue.main.async { self.ballView!.updateLocation(multiplier: 5000) }
3.2.3 更新小球的位置
6/8 首页 上一页 4 5 6 7 8 下一页 尾页