From 645525cbf33b348bd04783af92b658b9c7ff7d30 Mon Sep 17 00:00:00 2001 From: "Stephen H. Gerstacker" Date: Thu, 1 Oct 2015 14:03:57 -0400 Subject: [PATCH 1/2] Swift 2 Updates for Follow My Finger - Xcode-upgraded code for Swift 2. - Consolidated touch handling into one method. - Added a gitignore for user files. --- Follow-My-Finger/.gitignore | 43 +++++++ .../FollowMyFinger.xcodeproj/project.pbxproj | 11 +- .../UserInterfaceState.xcuserstate | Bin 21997 -> 0 bytes .../xcschemes/FollowMyFinger.xcscheme | 112 ------------------ .../xcschemes/xcschememanagement.plist | 27 ----- Follow-My-Finger/FollowMyFinger/Info.plist | 2 +- .../FollowMyFinger/ViewController.swift | 98 +++++++-------- .../FollowMyFingerTests/Info.plist | 2 +- 8 files changed, 98 insertions(+), 197 deletions(-) create mode 100644 Follow-My-Finger/.gitignore delete mode 100644 Follow-My-Finger/FollowMyFinger.xcodeproj/project.xcworkspace/xcuserdata/linda.xcuserdatad/UserInterfaceState.xcuserstate delete mode 100644 Follow-My-Finger/FollowMyFinger.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/FollowMyFinger.xcscheme delete mode 100644 Follow-My-Finger/FollowMyFinger.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/Follow-My-Finger/.gitignore b/Follow-My-Finger/.gitignore new file mode 100644 index 0000000..988d2da --- /dev/null +++ b/Follow-My-Finger/.gitignore @@ -0,0 +1,43 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build \ No newline at end of file diff --git a/Follow-My-Finger/FollowMyFinger.xcodeproj/project.pbxproj b/Follow-My-Finger/FollowMyFinger.xcodeproj/project.pbxproj index 92ee69e..4bde38f 100644 --- a/Follow-My-Finger/FollowMyFinger.xcodeproj/project.pbxproj +++ b/Follow-My-Finger/FollowMyFinger.xcodeproj/project.pbxproj @@ -156,7 +156,9 @@ BF93D0A01B96530A0069610C /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0640; + LastSwiftMigration = 0700; + LastSwiftUpdateCheck = 0700; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = "Linda Dong"; TargetAttributes = { BF93D0A71B96530A0069610C = { @@ -276,6 +278,7 @@ COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -344,6 +347,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = FollowMyFinger/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "lindadong.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -354,6 +358,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = FollowMyFinger/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "lindadong.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -372,6 +377,7 @@ ); INFOPLIST_FILE = FollowMyFingerTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "lindadong.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FollowMyFinger.app/FollowMyFinger"; }; @@ -387,6 +393,7 @@ ); INFOPLIST_FILE = FollowMyFingerTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "lindadong.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FollowMyFinger.app/FollowMyFinger"; }; @@ -411,6 +418,7 @@ BF93D0C91B96530A0069610C /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; BF93D0CA1B96530A0069610C /* Build configuration list for PBXNativeTarget "FollowMyFingerTests" */ = { isa = XCConfigurationList; @@ -419,6 +427,7 @@ BF93D0CC1B96530A0069610C /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/Follow-My-Finger/FollowMyFinger.xcodeproj/project.xcworkspace/xcuserdata/linda.xcuserdatad/UserInterfaceState.xcuserstate b/Follow-My-Finger/FollowMyFinger.xcodeproj/project.xcworkspace/xcuserdata/linda.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index cf444851b43780bb250d23f68a4b66a1b4a85423..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21997 zcmdUX2Yi#&`u{oS9qDe;Ht9%5+O+9N)23~jrhBD@%BE$NQPMV)NNG!w0tJ!tBI3q{ z;+D4HK*TLe5xpWV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1855xxPHBJf}Rbd|LU{A@f$|T_KP&&T{G0Oc%6}^Vwft-asbDLD zD?%%j6-gE86`2*;6}c6K6(tqr6;&11icu9~E1D|WD_j-xD|#v}skp3SMa5MW*H)~o zSY2^X#r+kJRL55*R%cXOs>`cutLv+0R<~5os&-UE9KG6Ey|j8+_44W~s;{oTwt8jt z4b@LoAGWgAENg+a!aCeK&e~v|Zf&(Xte0A;^(yPN)|J*9thZY?ST|Z9vp#9vWZi0g z*1E&`f_0~Lmvz7Op!IF*k(%n7u{Gms8fqrhY_EB(W_Qh-HG6B`ulb75hZ9(6CAW1BmFa AJOBUy diff --git a/Follow-My-Finger/FollowMyFinger.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/FollowMyFinger.xcscheme b/Follow-My-Finger/FollowMyFinger.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/FollowMyFinger.xcscheme deleted file mode 100644 index ee89d73..0000000 --- a/Follow-My-Finger/FollowMyFinger.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/FollowMyFinger.xcscheme +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Follow-My-Finger/FollowMyFinger.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/xcschememanagement.plist b/Follow-My-Finger/FollowMyFinger.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 8ec7463..0000000 --- a/Follow-My-Finger/FollowMyFinger.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - SchemeUserState - - FollowMyFinger.xcscheme - - orderHint - 0 - - - SuppressBuildableAutocreation - - BF93D0A71B96530A0069610C - - primary - - - BF93D0BC1B96530A0069610C - - primary - - - - - diff --git a/Follow-My-Finger/FollowMyFinger/Info.plist b/Follow-My-Finger/FollowMyFinger/Info.plist index 02f2c2f..9803469 100644 --- a/Follow-My-Finger/FollowMyFinger/Info.plist +++ b/Follow-My-Finger/FollowMyFinger/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - lindadong.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Follow-My-Finger/FollowMyFinger/ViewController.swift b/Follow-My-Finger/FollowMyFinger/ViewController.swift index 5d2e18c..17f5080 100644 --- a/Follow-My-Finger/FollowMyFinger/ViewController.swift +++ b/Follow-My-Finger/FollowMyFinger/ViewController.swift @@ -13,69 +13,57 @@ class ViewController: UIViewController { @IBOutlet weak var leftPupil: UIImageView! @IBOutlet weak var rightPupil: UIImageView! - - override func viewDidLoad() { - super.viewDidLoad() - // Do any additional setup after loading the view, typically from a nib. - } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. - } - - override func touchesBegan(touches: Set, withEvent event: UIEvent) { - if let touch:UITouch = touches.first as? UITouch { - - var touchPosition = touch.locationInView(self.view) - - // Gets the eye's center - let currentPositionL = leftPupil.frame.origin - let currentPositionR = rightPupil.frame.origin - - // Calculates angle between touch position and the eyes - var angleL = atan2(currentPositionL.y - touchPosition.y, currentPositionL.x - touchPosition.x) - var angleR = atan2(currentPositionR.y - touchPosition.y, currentPositionR.x - touchPosition.x) - - let duration : NSTimeInterval = 1.0 - let delay :NSTimeInterval = 1.0 - let damping : CGFloat = 0.3 - let animationVelocity : CGFloat = 0.5 + func handleTouch(touch: UITouch, animated: Bool) { + // Get the touch position + let touchPosition = touch.locationInView(self.view) + + // Gets the eye's center + let currentPositionL = leftPupil.frame.origin + let currentPositionR = rightPupil.frame.origin + + // Calculates angle between touch position and the eyes + let angleL = atan2(currentPositionL.y - touchPosition.y, currentPositionL.x - touchPosition.x) + let angleR = atan2(currentPositionR.y - touchPosition.y, currentPositionR.x - touchPosition.x) + + // Perform or animate + let operations = { + self.leftPupil.transform = CGAffineTransformMakeRotation(angleL + CGFloat(M_PI/2)) + self.rightPupil.transform = CGAffineTransformMakeRotation(angleR + CGFloat(M_PI/2)) + } + + if animated { + let duration: NSTimeInterval = 1.0 + let delay: NSTimeInterval = 0.0 + let damping: CGFloat = 0.3 + let animationVelocity: CGFloat = 0.5 - // usingSpringWithDamping UIView.animateWithDuration(duration, - delay: 0.0, + delay: delay, usingSpringWithDamping: damping, initialSpringVelocity: animationVelocity, - options: .CurveEaseInOut, - animations: { - self.leftPupil.transform = CGAffineTransformMakeRotation(angleL + CGFloat(M_PI/2)) - self.rightPupil.transform = CGAffineTransformMakeRotation(angleR + CGFloat(M_PI/2)) - }, - completion: {success in }) - - + options: .CurveEaseInOut, + animations: operations, + completion: { success in }) + } else { + operations() } } - override func touchesMoved(touches: Set, withEvent event: UIEvent) { - if let touch:UITouch = touches.first as? UITouch { - - var touchPosition = touch.locationInView(self.view) - - let currentPositionL = leftPupil.frame.origin - let currentPositionR = rightPupil.frame.origin - - var angleL = atan2(currentPositionL.y - touchPosition.y, currentPositionL.x - touchPosition.x) - var angleR = atan2(currentPositionR.y - touchPosition.y, currentPositionR.x - touchPosition.x) - - leftPupil.transform = CGAffineTransformMakeRotation(angleL + CGFloat(M_PI/2)) - rightPupil.transform = CGAffineTransformMakeRotation(angleR + CGFloat(M_PI/2)) - - + override func touchesBegan(touches: Set, withEvent event: UIEvent?) { + guard let touch = touches.first else { + return } + + handleTouch(touch, animated: true) } - - + + override func touchesMoved(touches: Set, withEvent event: UIEvent?) { + guard let touch = touches.first else { + return + } + + handleTouch(touch, animated: false) + } + } diff --git a/Follow-My-Finger/FollowMyFingerTests/Info.plist b/Follow-My-Finger/FollowMyFingerTests/Info.plist index fdde08f..ba72822 100644 --- a/Follow-My-Finger/FollowMyFingerTests/Info.plist +++ b/Follow-My-Finger/FollowMyFingerTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - lindadong.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From fc2e36402c306e0d3ee019fbc82f74af315ff898 Mon Sep 17 00:00:00 2001 From: "Stephen H. Gerstacker" Date: Thu, 1 Oct 2015 14:23:27 -0400 Subject: [PATCH 2/2] Swift 2 Updates for Accelerometer Soup - Xcode-upgraded code for Swift 2. - Other minor touch ups for Swift 2. - Added a gitignore for user files. --- Accelerometer-Soup/.gitignore | 43 +++++++ .../Accelerometer.xcodeproj/project.pbxproj | 9 +- .../UserInterfaceState.xcuserstate | Bin 23082 -> 0 bytes .../xcdebugger/Breakpoints_v2.xcbkptlist | 5 - .../xcschemes/Accelerometer.xcscheme | 112 ------------------ .../xcschemes/xcschememanagement.plist | 27 ----- .../Accelerometer/GameScene.swift | 34 +++--- .../Accelerometer/GameViewController.swift | 65 +++++----- Accelerometer-Soup/Accelerometer/Info.plist | 2 +- .../AccelerometerTests/Info.plist | 2 +- 10 files changed, 101 insertions(+), 198 deletions(-) create mode 100644 Accelerometer-Soup/.gitignore delete mode 100644 Accelerometer-Soup/Accelerometer.xcodeproj/project.xcworkspace/xcuserdata/linda.xcuserdatad/UserInterfaceState.xcuserstate delete mode 100644 Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist delete mode 100644 Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/Accelerometer.xcscheme delete mode 100644 Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/xcschememanagement.plist diff --git a/Accelerometer-Soup/.gitignore b/Accelerometer-Soup/.gitignore new file mode 100644 index 0000000..988d2da --- /dev/null +++ b/Accelerometer-Soup/.gitignore @@ -0,0 +1,43 @@ +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata + +## Other +*.xccheckout +*.moved-aside +*.xcuserstate +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build \ No newline at end of file diff --git a/Accelerometer-Soup/Accelerometer.xcodeproj/project.pbxproj b/Accelerometer-Soup/Accelerometer.xcodeproj/project.pbxproj index 9d87328..30f268c 100644 --- a/Accelerometer-Soup/Accelerometer.xcodeproj/project.pbxproj +++ b/Accelerometer-Soup/Accelerometer.xcodeproj/project.pbxproj @@ -164,7 +164,9 @@ BFE82E941B14202B008B6981 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0630; + LastSwiftMigration = 0700; + LastSwiftUpdateCheck = 0700; + LastUpgradeCheck = 0700; ORGANIZATIONNAME = "Linda Dong"; TargetAttributes = { BFE82E9B1B14202B008B6981 = { @@ -286,6 +288,7 @@ COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -354,6 +357,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Accelerometer/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "lindadong.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -364,6 +368,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = Accelerometer/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "lindadong.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; @@ -382,6 +387,7 @@ ); INFOPLIST_FILE = AccelerometerTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "lindadong.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Accelerometer.app/Accelerometer"; }; @@ -397,6 +403,7 @@ ); INFOPLIST_FILE = AccelerometerTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "lindadong.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Accelerometer.app/Accelerometer"; }; diff --git a/Accelerometer-Soup/Accelerometer.xcodeproj/project.xcworkspace/xcuserdata/linda.xcuserdatad/UserInterfaceState.xcuserstate b/Accelerometer-Soup/Accelerometer.xcodeproj/project.xcworkspace/xcuserdata/linda.xcuserdatad/UserInterfaceState.xcuserstate deleted file mode 100644 index 61b356887d9391cf3f4973c3edf8bf62c17e0950..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 23082 zcmdUX33yXQ*YM2U(!EKyv`s195}?pFdz|L_}0jaRC((H$*`JK@kx}R1g6b{m;#9+6D`+-}`>=^F6;0Hp!j2XU?2`&YYRL z)+W2ltyb?x7*U8u3}O){$(H1dPnl(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ks z@cgL!nEa%CW&XhY!TIU=>ikLhi}JVSf0h4Z{@MKV`4{tl&%azCD~K)VUyxLwEErIr zFEAD478Dee6bvmWFQ_b-SkPRsyx^gNbp=lqY$|xR;Dv(i1+NsmTCls|NWnJ+rwUFN zoGJLLkSb&g{R#sMM-@&eoK`rau%&Qj;jF^Bg*O!5Sa?riN8!_jn+l&Pe75k_!Z!-v zEZklAZsB`{pBEl3{G#y7qQOO3MMI0qi-s4CDyk|PTQs3)a?y;UmZF(O?xNX6^NQMw zNYTwjj})yhda3B0qQgaJivBROWKylHP188H@BM?nU|QC zneQ>*XMVuE!Mw%%ym_1XW%Ca6+vdIIL*{SIr_A4(Pn$29|1kemOck@mlH$nXODm=xbqd|UCt;zh+PiXSU}v3OVU zq2ixP*phxF#u7MTQ_@y4tK^oFMI}p0mX+L7@=(djl2s+EOCB#dSaPm3s5G)Pp)|Qv zRXV72NNGl?rZm5_v~*Z$Md^srn$q#5lS-$SURQcY=?kUDOHY@cvtUbzCDIaYQCQ+F zO3OgYU`x71Z82GLEJcF?++bN`x!>}rrNgquvd;3f zWwYfu%L|rmmNzW#SoT>yFDomnEUPK2FT1{MX4#Epi_7jRTVA%J?EbQc%2t+bDBD=J zsqERZtz|EiZ7X}J>{vNlo>4xbysmskxvTt!@|(&RmM<+|QNF%>L-~v4ub1yCf2(|V z`A6l4%fBf9vi$4vljYx)pDw>t{(Jf53RE$vVtU2(6-^b63cljDiaW(j21SXVlKigB KM%PEhUH=c&uswJH diff --git a/Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist deleted file mode 100644 index fe2b454..0000000 --- a/Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/Accelerometer.xcscheme b/Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/Accelerometer.xcscheme deleted file mode 100644 index bad89d0..0000000 --- a/Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/Accelerometer.xcscheme +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/xcschememanagement.plist b/Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index af24838..0000000 --- a/Accelerometer-Soup/Accelerometer.xcodeproj/xcuserdata/linda.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - SchemeUserState - - Accelerometer.xcscheme - - orderHint - 0 - - - SuppressBuildableAutocreation - - BFE82E9B1B14202B008B6981 - - primary - - - BFE82EB41B14202B008B6981 - - primary - - - - - diff --git a/Accelerometer-Soup/Accelerometer/GameScene.swift b/Accelerometer-Soup/Accelerometer/GameScene.swift index 13f62ec..ececabe 100644 --- a/Accelerometer-Soup/Accelerometer/GameScene.swift +++ b/Accelerometer-Soup/Accelerometer/GameScene.swift @@ -10,7 +10,7 @@ import SpriteKit import CoreMotion extension Array { - func sample() -> T { + func sample() -> Element { let randomIndex = Int(rand()) % count return self[randomIndex] } @@ -21,46 +21,45 @@ class GameScene: SKScene, SKPhysicsContactDelegate { let motionManager: CMMotionManager = CMMotionManager() // Shape Colors - let colorArray = [ SKColor(red: 0 / 255, green: 64 / 255, blue: 170 / 240, alpha: 1 ), + let colorArray = [ + SKColor(red: 0 / 255, green: 64 / 255, blue: 170 / 240, alpha: 1 ), SKColor(red: 255 / 255, green: 250 / 255, blue: 233 / 240, alpha: 1 ), - SKColor(red: 245 / 255, green: 122 / 255, blue: 99 / 240, alpha: 1 )] + SKColor(red: 245 / 255, green: 122 / 255, blue: 99 / 240, alpha: 1 ) + ] override func didMoveToView(view: SKView) { // Add physics to the borders of the screen let borderBody = SKPhysicsBody(edgeLoopFromRect: self.frame) borderBody.friction = 0 - self.physicsBody = borderBody + physicsBody = borderBody // Add gravity to the scene - self.physicsWorld.gravity = CGVectorMake(0, 0) - self.physicsWorld.contactDelegate = self - self.physicsBody?.contactTestBitMask = 0 + physicsWorld.gravity = CGVectorMake(0, 0) + physicsWorld.contactDelegate = self + physicsBody?.contactTestBitMask = 0 self.backgroundColor = SKColor(red: 255 / 255, green: 191 / 255, blue: 180 / 240, alpha: 1 ) // Create Shapes let maxShapes = 15 - for i in 0.. SKSpriteNode { // Chooses a random image for the shape - var randomShape = String("") - let shapes = ["triangle", "squiggle", "circle"] + let shapes = [ "triangle", "squiggle", "circle" ] let randomIndex = Int(arc4random_uniform(UInt32(shapes.count))) let shape = SKSpriteNode(imageNamed: shapes[randomIndex]) // Places shapes randomly within the bounds of the screen - var pointX = CGFloat(UInt(arc4random() % UInt32(UInt(self.frame.width - 100)))) - var pointY = CGFloat(UInt(arc4random() % UInt32(UInt(self.frame.height - 100)))) + let pointX = CGFloat(UInt(arc4random() % UInt32(UInt(frame.width - 100)))) + let pointY = CGFloat(UInt(arc4random() % UInt32(UInt(frame.height - 100)))) shape.position = CGPointMake(pointX, pointY) shape.name = "shape" @@ -69,7 +68,7 @@ class GameScene: SKScene, SKPhysicsContactDelegate { shape.colorBlendFactor = 1.0 // Adds physics properties to the shapes - shape.physicsBody = SKPhysicsBody(texture: shape.texture, size: shape.size) + shape.physicsBody = SKPhysicsBody(texture: shape.texture!, size: shape.size) shape.physicsBody?.dynamic = true shape.physicsBody?.restitution = 0.5 shape.physicsBody?.mass = 0.9 @@ -85,14 +84,13 @@ class GameScene: SKScene, SKPhysicsContactDelegate { // Changes the velocity of the scene's gravity based on the accelerometer if let data = motionManager.accelerometerData { self.physicsWorld.gravity = CGVectorMake(10 * CGFloat(data.acceleration.x), 10 * CGFloat(data.acceleration.y)) - } } override func didSimulatePhysics() { // For those pesky shapes that fall out of the scene - self.enumerateChildNodesWithName("shape", usingBlock: { (node: SKNode!, stop: UnsafeMutablePointer) -> Void in + self.enumerateChildNodesWithName("shape", usingBlock: { (node: SKNode, stop: UnsafeMutablePointer) -> Void in if node.position.y < 10 || node.position.x < 10 { node.removeFromParent() } @@ -102,6 +100,4 @@ class GameScene: SKScene, SKPhysicsContactDelegate { override func update(currentTime: CFTimeInterval) { processUserMotionForUpdate(currentTime) } - - } diff --git a/Accelerometer-Soup/Accelerometer/GameViewController.swift b/Accelerometer-Soup/Accelerometer/GameViewController.swift index 4b8cf6d..88dfa3a 100644 --- a/Accelerometer-Soup/Accelerometer/GameViewController.swift +++ b/Accelerometer-Soup/Accelerometer/GameViewController.swift @@ -11,17 +11,21 @@ import SpriteKit extension SKNode { class func unarchiveFromFile(file : String) -> SKNode? { - if let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks") { - var sceneData = NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe, error: nil)! - var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData) - - archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene") - let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as! GameScene - archiver.finishDecoding() - return scene - } else { + guard let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks") else { + return nil + } + + guard let sceneData = try? NSData(contentsOfFile: path, options: .DataReadingMappedIfSafe) else { return nil } + + let archiver = NSKeyedUnarchiver(forReadingWithData: sceneData) + + archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene") + let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as! GameScene + archiver.finishDecoding() + + return scene } } @@ -30,41 +34,38 @@ class GameViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene { - // Configure the view. - let skView = self.view as! SKView -// skView.showsFPS = true -// skView.showsNodeCount = true -// skView.showsPhysics = false - - /* Sprite Kit applies additional optimizations to improve rendering performance */ - skView.ignoresSiblingOrder = true - - /* Set the scale mode to scale to fit the window */ - scene.scaleMode = .ResizeFill - scene.size = skView.bounds.size - - skView.presentScene(scene) + guard let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene else { + return } + + // Configure the view. + let skView = self.view as! SKView +// skView.showsFPS = true +// skView.showsNodeCount = true +// skView.showsPhysics = false + + /* Sprite Kit applies additional optimizations to improve rendering performance */ + skView.ignoresSiblingOrder = true + + /* Set the scale mode to scale to fit the window */ + scene.scaleMode = .ResizeFill + scene.size = skView.bounds.size + + skView.presentScene(scene) } override func shouldAutorotate() -> Bool { return true } - override func supportedInterfaceOrientations() -> Int { + override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { if UIDevice.currentDevice().userInterfaceIdiom == .Phone { - return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue) + return UIInterfaceOrientationMask.AllButUpsideDown } else { - return Int(UIInterfaceOrientationMask.All.rawValue) + return UIInterfaceOrientationMask.All } } - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Release any cached data, images, etc that aren't in use. - } - override func prefersStatusBarHidden() -> Bool { return true } diff --git a/Accelerometer-Soup/Accelerometer/Info.plist b/Accelerometer-Soup/Accelerometer/Info.plist index 200fa71..44468d2 100644 --- a/Accelerometer-Soup/Accelerometer/Info.plist +++ b/Accelerometer-Soup/Accelerometer/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - lindadong.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/Accelerometer-Soup/AccelerometerTests/Info.plist b/Accelerometer-Soup/AccelerometerTests/Info.plist index fdde08f..ba72822 100644 --- a/Accelerometer-Soup/AccelerometerTests/Info.plist +++ b/Accelerometer-Soup/AccelerometerTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - lindadong.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName