Animation when activating parts of the background cube

This commit is contained in:
Charles Magahern
2015-12-30 16:56:15 -08:00
parent 9cfd75fa64
commit 00fcca6893
2 changed files with 84 additions and 8 deletions
@@ -11,6 +11,8 @@ import UIKit
class MainViewController: UIViewController {
private var _backgroundController: BackgroundViewController = BackgroundViewController()
// MARK: Overrides
override func viewDidLoad()
{
super.viewDidLoad()
@@ -19,6 +21,15 @@ class MainViewController: UIViewController {
self.addChildViewController(_backgroundController)
self.view.addSubview(_backgroundController.view)
let doubleTapGR = UITapGestureRecognizer(target: self, action: Selector("_handleDoubleFingerTap:"))
doubleTapGR.numberOfTouchesRequired = 2
self.view.addGestureRecognizer(doubleTapGR)
let singleTapGR = UITapGestureRecognizer(target: self, action: Selector("_handleSingleFingerTap:"))
singleTapGR.numberOfTouchesRequired = 1
singleTapGR.requireGestureRecognizerToFail(doubleTapGR)
self.view.addGestureRecognizer(singleTapGR)
}
override func prefersStatusBarHidden() -> Bool
@@ -33,4 +44,17 @@ class MainViewController: UIViewController {
let bounds = self.view.bounds
_backgroundController.view.frame = bounds
}
// MARK: Internal
internal func _handleSingleFingerTap(gestureRecognizer: UITapGestureRecognizer)
{
let randomPercentage = Float(arc4random()) / Float(UInt32.max)
_backgroundController.setPercentActivated(randomPercentage, animated: true)
}
internal func _handleDoubleFingerTap(gestureRecognizer: UITapGestureRecognizer)
{
_backgroundController.setPercentActivated(0.0, animated: true)
}
}