-
Notifications
You must be signed in to change notification settings - Fork 224
Complete Project - Cora Jacobson #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>IDEDidComputeMac32BitWarning</key> | ||
| <true/> | ||
| </dict> | ||
| </plist> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
| <plist version="1.0"> | ||
| <dict> | ||
| <key>SchemeUserState</key> | ||
| <dict> | ||
| <key>Contained.xcscheme_^#shared#^_</key> | ||
| <dict> | ||
| <key>orderHint</key> | ||
| <integer>0</integer> | ||
| </dict> | ||
| </dict> | ||
| </dict> | ||
| </plist> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // | ||
| // AppDelegate.swift | ||
| // Contained | ||
| // | ||
| // Created by Cora Jacobson on 6/2/20. | ||
| // Copyright © 2020 Cora Jacobson. All rights reserved. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| @UIApplicationMain | ||
| class AppDelegate: UIResponder, UIApplicationDelegate { | ||
|
|
||
|
|
||
|
|
||
| func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | ||
| // Override point for customization after application launch. | ||
| return true | ||
| } | ||
|
|
||
| // MARK: UISceneSession Lifecycle | ||
|
|
||
| func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { | ||
| // Called when a new scene session is being created. | ||
| // Use this method to select a configuration to create the new scene with. | ||
| return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) | ||
| } | ||
|
|
||
| func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { | ||
| // Called when the user discards a scene session. | ||
| // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. | ||
| // Use this method to release any resources that were specific to the discarded scenes, as they will not return. | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "idiom" : "iphone", | ||
| "scale" : "2x", | ||
| "size" : "20x20" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "scale" : "3x", | ||
| "size" : "20x20" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "scale" : "2x", | ||
| "size" : "29x29" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "scale" : "3x", | ||
| "size" : "29x29" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "scale" : "2x", | ||
| "size" : "40x40" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "scale" : "3x", | ||
| "size" : "40x40" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "scale" : "2x", | ||
| "size" : "60x60" | ||
| }, | ||
| { | ||
| "idiom" : "iphone", | ||
| "scale" : "3x", | ||
| "size" : "60x60" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "scale" : "1x", | ||
| "size" : "20x20" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "scale" : "2x", | ||
| "size" : "20x20" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "scale" : "1x", | ||
| "size" : "29x29" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "scale" : "2x", | ||
| "size" : "29x29" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "scale" : "1x", | ||
| "size" : "40x40" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "scale" : "2x", | ||
| "size" : "40x40" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "scale" : "1x", | ||
| "size" : "76x76" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "scale" : "2x", | ||
| "size" : "76x76" | ||
| }, | ||
| { | ||
| "idiom" : "ipad", | ||
| "scale" : "2x", | ||
| "size" : "83.5x83.5" | ||
| }, | ||
| { | ||
| "idiom" : "ios-marketing", | ||
| "scale" : "1x", | ||
| "size" : "1024x1024" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "game_controller.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "filename" : "game_controller@2x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "filename" : "game_controller@3x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "info.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "filename" : "info@2x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "filename" : "info@3x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "settings.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "filename" : "settings@2x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "filename" : "settings@3x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
| <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
| <dependencies> | ||
| <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> | ||
| <capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
| <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
| </dependencies> | ||
| <scenes> | ||
| <!--View Controller--> | ||
| <scene sceneID="EHf-IW-A2E"> | ||
| <objects> | ||
| <viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
| <view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
| <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
| <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
| <color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | ||
| <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | ||
| </view> | ||
| </viewController> | ||
| <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
| </objects> | ||
| <point key="canvasLocation" x="53" y="375"/> | ||
| </scene> | ||
| </scenes> | ||
| </document> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| // | ||
| // CustomScene.swift | ||
| // Contained | ||
| // | ||
| // Created by Cora Jacobson on 6/3/20. | ||
| // Copyright © 2020 Cora Jacobson. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| import SpriteKit | ||
|
|
||
| class CustomScene: SKScene { | ||
| let crab = SKSpriteNode() | ||
|
|
||
| // Add and center child, initializing animation sequence | ||
| override func sceneDidLoad() { | ||
| super.sceneDidLoad() | ||
| addChild(crab) | ||
| if Settings.shared.texture == "HappyCrab" { | ||
| crab.loadTextures(named: "HappyCrab", forKey: SKSpriteNode.textureKey) | ||
| } else { | ||
| crab.loadTextures(named: "WaitingCrab", forKey: SKSpriteNode.textureKey) | ||
| } | ||
|
|
||
| if let lastPosition = Settings.shared.lastPosition { | ||
| crab.position = lastPosition | ||
| } else { | ||
| crab.position = CGPoint(x: frame.midX, y: frame.midY) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // Move to touch | ||
| public override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { | ||
|
|
||
| // Fetch a touch or leave | ||
| guard !touches.isEmpty, let touch = touches.first else { return } | ||
|
|
||
| // Retrieve position | ||
| let position = touch.location(in: self) | ||
|
|
||
| Settings.shared.lastPosition = position | ||
|
|
||
| // Create move action | ||
| let actionDuration = 1.0 | ||
| let moveAction = SKAction.move(to: position, duration: actionDuration) | ||
|
|
||
| let rollAction = SKAction.rotate(byAngle: CGFloat.pi * 2, duration: actionDuration) | ||
| let zoomAction = SKAction.scale(by: 1.3, duration: 0.3) | ||
| let unzoomAction = SKAction.scale(to: 1.0, duration: 0.1) | ||
| let fadeOutAction = SKAction.fadeOut(withDuration: actionDuration / 2) | ||
| let fadeInAction = SKAction.fadeIn(withDuration: actionDuration / 2) | ||
| let danceStartAction = SKAction.rotate(byAngle: -(CGFloat.pi * 0.25), duration: actionDuration / 12) | ||
| let danceRightAction = SKAction.rotate(byAngle: CGFloat.pi * 0.5, duration: actionDuration / 6) | ||
| let danceLeftAction = SKAction.rotate(byAngle: -(CGFloat.pi * 0.5), duration: actionDuration / 6) | ||
| let danceEndAction = SKAction.rotate(byAngle: CGFloat.pi * 0.25, duration: actionDuration / 12) | ||
|
|
||
| switch Settings.shared.shouldZoom { | ||
| case false: | ||
| crab.run(moveAction) | ||
| case true: | ||
| let sequenceAction = SKAction.sequence([zoomAction, moveAction, unzoomAction]) | ||
| crab.run(sequenceAction) | ||
| } | ||
|
|
||
| if Settings.shared.shouldRoll { | ||
| crab.run(rollAction) | ||
| } | ||
|
|
||
| switch Settings.shared.shouldFade { | ||
| case false: | ||
| crab.run(moveAction) | ||
| case true: | ||
| let sequenceAction = SKAction.sequence([fadeOutAction, fadeInAction, moveAction]) | ||
| crab.run(sequenceAction) | ||
| } | ||
|
|
||
| if Settings.shared.shouldDance { | ||
| let sequenceAction = SKAction.sequence([danceStartAction, danceRightAction, danceLeftAction, danceRightAction, danceLeftAction, danceRightAction, danceLeftAction, danceEndAction, moveAction]) | ||
| crab.run(sequenceAction) | ||
| } | ||
|
Comment on lines
+79
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great! One thing I will say, is with long lines like this, most places have a line limit that they like to stick to, so you might consider putting a return in there somewhere, or even putting each item on it's own line. It's all personal style though (you will have to use a linter later in the course which basically enforces some formatting rules). |
||
|
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job figuring out the position persistence