Commit d8781b90 authored by toby's avatar toby

shake to change barrier color

parent 2543329e
......@@ -52,6 +52,8 @@ class ViewController: UIViewController {
var machine: StateMachine<ViewController>!
var backgroundTransition: BGTransition!
var barriers: [UIView] = [UIView]()
override func viewDidLoad() {
super.viewDidLoad()
......@@ -63,6 +65,7 @@ class ViewController: UIViewController {
let barrier = UIView(frame: CGRectFromOrigin(view, 0, 40, 130, 20))
barrier.backgroundColor = randomColor()
view.addSubview(barrier)
barriers.append(barrier)
// Setup gravity
gravity = UIGravityBehavior()
......@@ -93,6 +96,12 @@ class ViewController: UIViewController {
// Dispose of any resources that can be recreated.
}
override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent) {
if motion == .MotionShake {
barriers.map({barrier in barrier.backgroundColor = randomColor()})
}
}
private func animateBackground() -> Void {
UIView.animateWithDuration(
self.backgroundTransition.duration,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment