Commit d395992e authored by toby's avatar toby

print state, filter blocks, temp other stuff

parent 844ad25b
......@@ -9,6 +9,24 @@
import UIKit
func backgroundStateToString(state: BackgroundState) -> String {
switch(state) {
case (.Ready):
return "Ready"
case (.AnimatingBackground):
return "AnimatingBackground"
case (.AddBlock(let block)):
return "AddBlock"
case (.RemoveBlock(let block)):
return "RemoveBlock"
case (.PausedBackground):
return "PausedBackground"
case (.Finished):
return "Finished"
}
}
enum BackgroundState:StateMachineDataSource{
case Ready, AnimatingBackground, AddBlock(UIView), RemoveBlock(UIView), PausedBackground, Finished
......@@ -60,8 +78,12 @@ extension WorldViewController: StateMachineDelegate {
case (.Ready, .AnimatingBackground), (.Finished, .AnimatingBackground):
animateBackground()
case (.AnimatingBackground, .PausedBackground):
pausedBackgroundColor = background.backgroundColor!
background.pause()
case (.PausedBackground, .AnimatingBackground), (.PausedBackground, .Finished):
var n: UIColor?
n = nil
pausedBackgroundColor = n
background.unpause()
case (.AnimatingBackground, .Finished):
machine.state = .AnimatingBackground
......@@ -88,6 +110,7 @@ class WorldViewController: UIViewController {
var background: UIView!
var backgroundTransition: BGTransition!
var pausedBackgroundColor: UIColor?
var blocks: [UIView] = [UIView]()
var barriers: [UIView] = [UIView]()
var flipButton: UIButton!
......@@ -238,7 +261,7 @@ class WorldViewController: UIViewController {
block.removeFromSuperview()
self.gravity.removeItem(block)
self.collision.removeItem(block)
self.blocks.filter({ $0 != block })
self.blocks = self.blocks.filter({ $0 != block })
})
}
......@@ -256,6 +279,7 @@ class WorldViewController: UIViewController {
}
@IBAction func backgroundHeld(hold: UILongPressGestureRecognizer) {
println("machine.state: \(backgroundStateToString(machine.state))")
switch hold.state {
case UIGestureRecognizerState.Began:
machine.state = .AnimatingBackground
......@@ -283,7 +307,12 @@ class WorldViewController: UIViewController {
var colors = [UIColor]()
colors = blocks.map({ return $0.backgroundColor! })
colors += barriers.map({ return $0.backgroundColor! })
colors.append(background.backgroundColor!)
if pausedBackgroundColor != nil {
println("doing paused")
colors.append(pausedBackgroundColor!)
} else {
colors.append(background.backgroundColor!)
}
colorDetail.colors = colors
navigationController!.pushViewController(colorDetail, animated: true)
}
......
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