├── README.md ├── SpriteKitScrollingNode.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcuserdata │ └── Jen.xcuserdatad │ └── xcschemes │ ├── SpriteKitScrollingNode.xcscheme │ └── xcschememanagement.plist ├── SpriteKitScrollingNode ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── JADAppDelegate.h ├── JADAppDelegate.m ├── JADMainScene.h ├── JADMainScene.m ├── JADPartScrollingScene.h ├── JADPartScrollingScene.m ├── JADSKScrollingNode.h ├── JADSKScrollingNode.m ├── JADViewController.h ├── JADViewController.m ├── SpriteKitScrollingNode-Info.plist ├── SpriteKitScrollingNode-Prefix.pch ├── en.lproj │ └── InfoPlist.strings └── main.m └── SpriteKitScrollingNodeTests ├── SpriteKitScrollingNodeTests-Info.plist ├── SpriteKitScrollingNodeTests.m └── en.lproj └── InfoPlist.strings /README.md: -------------------------------------------------------------------------------- 1 | SpriteKitScrollingNode 2 | ====================== 3 | 4 | Example app that demonstrates subclassing SKNode to make a scrolling node on an SKScene. 5 | 6 | This app launches a game in landscape mode. The view is instaniated programmatically, so there are no nib files or storyboards. 7 | 8 | To use the JADSKScrollingNode on your own scene, call JADSKScrollingNode's `enableScrollingOnView:` method in the implementation of your scene's `didMoveToView` method and call the `disableScrollingOnView` method on your implementation of the scene's `willMoveFromView` method. JADSKScrollingNode's `enableScrollingOnView` and `disableScrollingOnView` adds and removes the `UIPanGestureRecognizer` from the `SKView` that contains the scene. -------------------------------------------------------------------------------- /SpriteKitScrollingNode.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BD72022C19832DCE00DB4AB1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD72022B19832DCE00DB4AB1 /* Foundation.framework */; }; 11 | BD72022E19832DCE00DB4AB1 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD72022D19832DCE00DB4AB1 /* CoreGraphics.framework */; }; 12 | BD72023019832DCE00DB4AB1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD72022F19832DCE00DB4AB1 /* UIKit.framework */; }; 13 | BD72023619832DCE00DB4AB1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BD72023419832DCE00DB4AB1 /* InfoPlist.strings */; }; 14 | BD72023819832DCE00DB4AB1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BD72023719832DCE00DB4AB1 /* main.m */; }; 15 | BD72023C19832DCE00DB4AB1 /* JADAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = BD72023B19832DCE00DB4AB1 /* JADAppDelegate.m */; }; 16 | BD72023E19832DCE00DB4AB1 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BD72023D19832DCE00DB4AB1 /* Images.xcassets */; }; 17 | BD72024519832DCE00DB4AB1 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD72024419832DCE00DB4AB1 /* XCTest.framework */; }; 18 | BD72024619832DCE00DB4AB1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD72022B19832DCE00DB4AB1 /* Foundation.framework */; }; 19 | BD72024719832DCE00DB4AB1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BD72022F19832DCE00DB4AB1 /* UIKit.framework */; }; 20 | BD72024F19832DCE00DB4AB1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = BD72024D19832DCE00DB4AB1 /* InfoPlist.strings */; }; 21 | BD72025119832DCE00DB4AB1 /* SpriteKitScrollingNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = BD72025019832DCE00DB4AB1 /* SpriteKitScrollingNodeTests.m */; }; 22 | BD72025F19832E7A00DB4AB1 /* JADViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BD72025E19832E7A00DB4AB1 /* JADViewController.m */; }; 23 | BD72026219832F8E00DB4AB1 /* JADMainScene.m in Sources */ = {isa = PBXBuildFile; fileRef = BD72026119832F8E00DB4AB1 /* JADMainScene.m */; }; 24 | BD9F8B5B19855FFC0098D4C6 /* JADSKScrollingNode.m in Sources */ = {isa = PBXBuildFile; fileRef = BD9F8B5A19855FFC0098D4C6 /* JADSKScrollingNode.m */; }; 25 | BDB4182819A0281E006FA7E1 /* JADPartScrollingScene.m in Sources */ = {isa = PBXBuildFile; fileRef = BDB4182719A0281E006FA7E1 /* JADPartScrollingScene.m */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | BD72024819832DCE00DB4AB1 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = BD72022019832DCE00DB4AB1 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = BD72022719832DCE00DB4AB1; 34 | remoteInfo = SpriteKitScrollingNode; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | BD72022819832DCE00DB4AB1 /* SpriteKitScrollingNode.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpriteKitScrollingNode.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | BD72022B19832DCE00DB4AB1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 41 | BD72022D19832DCE00DB4AB1 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 42 | BD72022F19832DCE00DB4AB1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 43 | BD72023319832DCE00DB4AB1 /* SpriteKitScrollingNode-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SpriteKitScrollingNode-Info.plist"; sourceTree = ""; }; 44 | BD72023519832DCE00DB4AB1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 45 | BD72023719832DCE00DB4AB1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 46 | BD72023919832DCE00DB4AB1 /* SpriteKitScrollingNode-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SpriteKitScrollingNode-Prefix.pch"; sourceTree = ""; }; 47 | BD72023A19832DCE00DB4AB1 /* JADAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JADAppDelegate.h; sourceTree = ""; }; 48 | BD72023B19832DCE00DB4AB1 /* JADAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = JADAppDelegate.m; sourceTree = ""; }; 49 | BD72023D19832DCE00DB4AB1 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 50 | BD72024319832DCE00DB4AB1 /* SpriteKitScrollingNodeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SpriteKitScrollingNodeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | BD72024419832DCE00DB4AB1 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 52 | BD72024C19832DCE00DB4AB1 /* SpriteKitScrollingNodeTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SpriteKitScrollingNodeTests-Info.plist"; sourceTree = ""; }; 53 | BD72024E19832DCE00DB4AB1 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 54 | BD72025019832DCE00DB4AB1 /* SpriteKitScrollingNodeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SpriteKitScrollingNodeTests.m; sourceTree = ""; }; 55 | BD72025D19832E7A00DB4AB1 /* JADViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JADViewController.h; sourceTree = ""; }; 56 | BD72025E19832E7A00DB4AB1 /* JADViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JADViewController.m; sourceTree = ""; }; 57 | BD72026019832F8E00DB4AB1 /* JADMainScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JADMainScene.h; sourceTree = ""; }; 58 | BD72026119832F8E00DB4AB1 /* JADMainScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JADMainScene.m; sourceTree = ""; }; 59 | BD9F8B5919855FFC0098D4C6 /* JADSKScrollingNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JADSKScrollingNode.h; sourceTree = ""; }; 60 | BD9F8B5A19855FFC0098D4C6 /* JADSKScrollingNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JADSKScrollingNode.m; sourceTree = ""; }; 61 | BDB4182619A0281E006FA7E1 /* JADPartScrollingScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JADPartScrollingScene.h; sourceTree = ""; }; 62 | BDB4182719A0281E006FA7E1 /* JADPartScrollingScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JADPartScrollingScene.m; sourceTree = ""; }; 63 | /* End PBXFileReference section */ 64 | 65 | /* Begin PBXFrameworksBuildPhase section */ 66 | BD72022519832DCE00DB4AB1 /* Frameworks */ = { 67 | isa = PBXFrameworksBuildPhase; 68 | buildActionMask = 2147483647; 69 | files = ( 70 | BD72022E19832DCE00DB4AB1 /* CoreGraphics.framework in Frameworks */, 71 | BD72023019832DCE00DB4AB1 /* UIKit.framework in Frameworks */, 72 | BD72022C19832DCE00DB4AB1 /* Foundation.framework in Frameworks */, 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | BD72024019832DCE00DB4AB1 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | BD72024519832DCE00DB4AB1 /* XCTest.framework in Frameworks */, 81 | BD72024719832DCE00DB4AB1 /* UIKit.framework in Frameworks */, 82 | BD72024619832DCE00DB4AB1 /* Foundation.framework in Frameworks */, 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | }; 86 | /* End PBXFrameworksBuildPhase section */ 87 | 88 | /* Begin PBXGroup section */ 89 | BD72021F19832DCD00DB4AB1 = { 90 | isa = PBXGroup; 91 | children = ( 92 | BD72023119832DCE00DB4AB1 /* SpriteKitScrollingNode */, 93 | BD72024A19832DCE00DB4AB1 /* SpriteKitScrollingNodeTests */, 94 | BD72022A19832DCE00DB4AB1 /* Frameworks */, 95 | BD72022919832DCE00DB4AB1 /* Products */, 96 | ); 97 | sourceTree = ""; 98 | }; 99 | BD72022919832DCE00DB4AB1 /* Products */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | BD72022819832DCE00DB4AB1 /* SpriteKitScrollingNode.app */, 103 | BD72024319832DCE00DB4AB1 /* SpriteKitScrollingNodeTests.xctest */, 104 | ); 105 | name = Products; 106 | sourceTree = ""; 107 | }; 108 | BD72022A19832DCE00DB4AB1 /* Frameworks */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | BD72022B19832DCE00DB4AB1 /* Foundation.framework */, 112 | BD72022D19832DCE00DB4AB1 /* CoreGraphics.framework */, 113 | BD72022F19832DCE00DB4AB1 /* UIKit.framework */, 114 | BD72024419832DCE00DB4AB1 /* XCTest.framework */, 115 | ); 116 | name = Frameworks; 117 | sourceTree = ""; 118 | }; 119 | BD72023119832DCE00DB4AB1 /* SpriteKitScrollingNode */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | BD72023A19832DCE00DB4AB1 /* JADAppDelegate.h */, 123 | BD72023B19832DCE00DB4AB1 /* JADAppDelegate.m */, 124 | BD72025D19832E7A00DB4AB1 /* JADViewController.h */, 125 | BD72025E19832E7A00DB4AB1 /* JADViewController.m */, 126 | BD72026019832F8E00DB4AB1 /* JADMainScene.h */, 127 | BD72026119832F8E00DB4AB1 /* JADMainScene.m */, 128 | BDB4182619A0281E006FA7E1 /* JADPartScrollingScene.h */, 129 | BDB4182719A0281E006FA7E1 /* JADPartScrollingScene.m */, 130 | BD9F8B5919855FFC0098D4C6 /* JADSKScrollingNode.h */, 131 | BD9F8B5A19855FFC0098D4C6 /* JADSKScrollingNode.m */, 132 | BD72023D19832DCE00DB4AB1 /* Images.xcassets */, 133 | BD72023219832DCE00DB4AB1 /* Supporting Files */, 134 | ); 135 | path = SpriteKitScrollingNode; 136 | sourceTree = ""; 137 | }; 138 | BD72023219832DCE00DB4AB1 /* Supporting Files */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | BD72023319832DCE00DB4AB1 /* SpriteKitScrollingNode-Info.plist */, 142 | BD72023419832DCE00DB4AB1 /* InfoPlist.strings */, 143 | BD72023719832DCE00DB4AB1 /* main.m */, 144 | BD72023919832DCE00DB4AB1 /* SpriteKitScrollingNode-Prefix.pch */, 145 | ); 146 | name = "Supporting Files"; 147 | sourceTree = ""; 148 | }; 149 | BD72024A19832DCE00DB4AB1 /* SpriteKitScrollingNodeTests */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | BD72025019832DCE00DB4AB1 /* SpriteKitScrollingNodeTests.m */, 153 | BD72024B19832DCE00DB4AB1 /* Supporting Files */, 154 | ); 155 | path = SpriteKitScrollingNodeTests; 156 | sourceTree = ""; 157 | }; 158 | BD72024B19832DCE00DB4AB1 /* Supporting Files */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | BD72024C19832DCE00DB4AB1 /* SpriteKitScrollingNodeTests-Info.plist */, 162 | BD72024D19832DCE00DB4AB1 /* InfoPlist.strings */, 163 | ); 164 | name = "Supporting Files"; 165 | sourceTree = ""; 166 | }; 167 | /* End PBXGroup section */ 168 | 169 | /* Begin PBXNativeTarget section */ 170 | BD72022719832DCE00DB4AB1 /* SpriteKitScrollingNode */ = { 171 | isa = PBXNativeTarget; 172 | buildConfigurationList = BD72025419832DCE00DB4AB1 /* Build configuration list for PBXNativeTarget "SpriteKitScrollingNode" */; 173 | buildPhases = ( 174 | BD72022419832DCE00DB4AB1 /* Sources */, 175 | BD72022519832DCE00DB4AB1 /* Frameworks */, 176 | BD72022619832DCE00DB4AB1 /* Resources */, 177 | ); 178 | buildRules = ( 179 | ); 180 | dependencies = ( 181 | ); 182 | name = SpriteKitScrollingNode; 183 | productName = SpriteKitScrollingNode; 184 | productReference = BD72022819832DCE00DB4AB1 /* SpriteKitScrollingNode.app */; 185 | productType = "com.apple.product-type.application"; 186 | }; 187 | BD72024219832DCE00DB4AB1 /* SpriteKitScrollingNodeTests */ = { 188 | isa = PBXNativeTarget; 189 | buildConfigurationList = BD72025719832DCE00DB4AB1 /* Build configuration list for PBXNativeTarget "SpriteKitScrollingNodeTests" */; 190 | buildPhases = ( 191 | BD72023F19832DCE00DB4AB1 /* Sources */, 192 | BD72024019832DCE00DB4AB1 /* Frameworks */, 193 | BD72024119832DCE00DB4AB1 /* Resources */, 194 | ); 195 | buildRules = ( 196 | ); 197 | dependencies = ( 198 | BD72024919832DCE00DB4AB1 /* PBXTargetDependency */, 199 | ); 200 | name = SpriteKitScrollingNodeTests; 201 | productName = SpriteKitScrollingNodeTests; 202 | productReference = BD72024319832DCE00DB4AB1 /* SpriteKitScrollingNodeTests.xctest */; 203 | productType = "com.apple.product-type.bundle.unit-test"; 204 | }; 205 | /* End PBXNativeTarget section */ 206 | 207 | /* Begin PBXProject section */ 208 | BD72022019832DCE00DB4AB1 /* Project object */ = { 209 | isa = PBXProject; 210 | attributes = { 211 | CLASSPREFIX = JAD; 212 | LastUpgradeCheck = 0510; 213 | ORGANIZATIONNAME = "Jennifer Dobson"; 214 | TargetAttributes = { 215 | BD72024219832DCE00DB4AB1 = { 216 | TestTargetID = BD72022719832DCE00DB4AB1; 217 | }; 218 | }; 219 | }; 220 | buildConfigurationList = BD72022319832DCE00DB4AB1 /* Build configuration list for PBXProject "SpriteKitScrollingNode" */; 221 | compatibilityVersion = "Xcode 3.2"; 222 | developmentRegion = English; 223 | hasScannedForEncodings = 0; 224 | knownRegions = ( 225 | en, 226 | ); 227 | mainGroup = BD72021F19832DCD00DB4AB1; 228 | productRefGroup = BD72022919832DCE00DB4AB1 /* Products */; 229 | projectDirPath = ""; 230 | projectRoot = ""; 231 | targets = ( 232 | BD72022719832DCE00DB4AB1 /* SpriteKitScrollingNode */, 233 | BD72024219832DCE00DB4AB1 /* SpriteKitScrollingNodeTests */, 234 | ); 235 | }; 236 | /* End PBXProject section */ 237 | 238 | /* Begin PBXResourcesBuildPhase section */ 239 | BD72022619832DCE00DB4AB1 /* Resources */ = { 240 | isa = PBXResourcesBuildPhase; 241 | buildActionMask = 2147483647; 242 | files = ( 243 | BD72023619832DCE00DB4AB1 /* InfoPlist.strings in Resources */, 244 | BD72023E19832DCE00DB4AB1 /* Images.xcassets in Resources */, 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | BD72024119832DCE00DB4AB1 /* Resources */ = { 249 | isa = PBXResourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | BD72024F19832DCE00DB4AB1 /* InfoPlist.strings in Resources */, 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | /* End PBXResourcesBuildPhase section */ 257 | 258 | /* Begin PBXSourcesBuildPhase section */ 259 | BD72022419832DCE00DB4AB1 /* Sources */ = { 260 | isa = PBXSourcesBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | BD72023C19832DCE00DB4AB1 /* JADAppDelegate.m in Sources */, 264 | BD9F8B5B19855FFC0098D4C6 /* JADSKScrollingNode.m in Sources */, 265 | BD72026219832F8E00DB4AB1 /* JADMainScene.m in Sources */, 266 | BD72025F19832E7A00DB4AB1 /* JADViewController.m in Sources */, 267 | BD72023819832DCE00DB4AB1 /* main.m in Sources */, 268 | BDB4182819A0281E006FA7E1 /* JADPartScrollingScene.m in Sources */, 269 | ); 270 | runOnlyForDeploymentPostprocessing = 0; 271 | }; 272 | BD72023F19832DCE00DB4AB1 /* Sources */ = { 273 | isa = PBXSourcesBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | BD72025119832DCE00DB4AB1 /* SpriteKitScrollingNodeTests.m in Sources */, 277 | ); 278 | runOnlyForDeploymentPostprocessing = 0; 279 | }; 280 | /* End PBXSourcesBuildPhase section */ 281 | 282 | /* Begin PBXTargetDependency section */ 283 | BD72024919832DCE00DB4AB1 /* PBXTargetDependency */ = { 284 | isa = PBXTargetDependency; 285 | target = BD72022719832DCE00DB4AB1 /* SpriteKitScrollingNode */; 286 | targetProxy = BD72024819832DCE00DB4AB1 /* PBXContainerItemProxy */; 287 | }; 288 | /* End PBXTargetDependency section */ 289 | 290 | /* Begin PBXVariantGroup section */ 291 | BD72023419832DCE00DB4AB1 /* InfoPlist.strings */ = { 292 | isa = PBXVariantGroup; 293 | children = ( 294 | BD72023519832DCE00DB4AB1 /* en */, 295 | ); 296 | name = InfoPlist.strings; 297 | sourceTree = ""; 298 | }; 299 | BD72024D19832DCE00DB4AB1 /* InfoPlist.strings */ = { 300 | isa = PBXVariantGroup; 301 | children = ( 302 | BD72024E19832DCE00DB4AB1 /* en */, 303 | ); 304 | name = InfoPlist.strings; 305 | sourceTree = ""; 306 | }; 307 | /* End PBXVariantGroup section */ 308 | 309 | /* Begin XCBuildConfiguration section */ 310 | BD72025219832DCE00DB4AB1 /* Debug */ = { 311 | isa = XCBuildConfiguration; 312 | buildSettings = { 313 | ALWAYS_SEARCH_USER_PATHS = NO; 314 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 315 | CLANG_CXX_LIBRARY = "libc++"; 316 | CLANG_ENABLE_MODULES = YES; 317 | CLANG_ENABLE_OBJC_ARC = YES; 318 | CLANG_WARN_BOOL_CONVERSION = YES; 319 | CLANG_WARN_CONSTANT_CONVERSION = YES; 320 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 321 | CLANG_WARN_EMPTY_BODY = YES; 322 | CLANG_WARN_ENUM_CONVERSION = YES; 323 | CLANG_WARN_INT_CONVERSION = YES; 324 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 325 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 326 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 327 | COPY_PHASE_STRIP = NO; 328 | GCC_C_LANGUAGE_STANDARD = gnu99; 329 | GCC_DYNAMIC_NO_PIC = NO; 330 | GCC_OPTIMIZATION_LEVEL = 0; 331 | GCC_PREPROCESSOR_DEFINITIONS = ( 332 | "DEBUG=1", 333 | "$(inherited)", 334 | ); 335 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 336 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 337 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 338 | GCC_WARN_UNDECLARED_SELECTOR = YES; 339 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 340 | GCC_WARN_UNUSED_FUNCTION = YES; 341 | GCC_WARN_UNUSED_VARIABLE = YES; 342 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 343 | ONLY_ACTIVE_ARCH = YES; 344 | SDKROOT = iphoneos; 345 | TARGETED_DEVICE_FAMILY = 2; 346 | }; 347 | name = Debug; 348 | }; 349 | BD72025319832DCE00DB4AB1 /* Release */ = { 350 | isa = XCBuildConfiguration; 351 | buildSettings = { 352 | ALWAYS_SEARCH_USER_PATHS = NO; 353 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 354 | CLANG_CXX_LIBRARY = "libc++"; 355 | CLANG_ENABLE_MODULES = YES; 356 | CLANG_ENABLE_OBJC_ARC = YES; 357 | CLANG_WARN_BOOL_CONVERSION = YES; 358 | CLANG_WARN_CONSTANT_CONVERSION = YES; 359 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 360 | CLANG_WARN_EMPTY_BODY = YES; 361 | CLANG_WARN_ENUM_CONVERSION = YES; 362 | CLANG_WARN_INT_CONVERSION = YES; 363 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 366 | COPY_PHASE_STRIP = YES; 367 | ENABLE_NS_ASSERTIONS = NO; 368 | GCC_C_LANGUAGE_STANDARD = gnu99; 369 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 370 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 371 | GCC_WARN_UNDECLARED_SELECTOR = YES; 372 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 373 | GCC_WARN_UNUSED_FUNCTION = YES; 374 | GCC_WARN_UNUSED_VARIABLE = YES; 375 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 376 | SDKROOT = iphoneos; 377 | TARGETED_DEVICE_FAMILY = 2; 378 | VALIDATE_PRODUCT = YES; 379 | }; 380 | name = Release; 381 | }; 382 | BD72025519832DCE00DB4AB1 /* Debug */ = { 383 | isa = XCBuildConfiguration; 384 | buildSettings = { 385 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 386 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 387 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 388 | GCC_PREFIX_HEADER = "SpriteKitScrollingNode/SpriteKitScrollingNode-Prefix.pch"; 389 | INFOPLIST_FILE = "SpriteKitScrollingNode/SpriteKitScrollingNode-Info.plist"; 390 | PRODUCT_NAME = "$(TARGET_NAME)"; 391 | WRAPPER_EXTENSION = app; 392 | }; 393 | name = Debug; 394 | }; 395 | BD72025619832DCE00DB4AB1 /* Release */ = { 396 | isa = XCBuildConfiguration; 397 | buildSettings = { 398 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 399 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 400 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 401 | GCC_PREFIX_HEADER = "SpriteKitScrollingNode/SpriteKitScrollingNode-Prefix.pch"; 402 | INFOPLIST_FILE = "SpriteKitScrollingNode/SpriteKitScrollingNode-Info.plist"; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | WRAPPER_EXTENSION = app; 405 | }; 406 | name = Release; 407 | }; 408 | BD72025819832DCE00DB4AB1 /* Debug */ = { 409 | isa = XCBuildConfiguration; 410 | buildSettings = { 411 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SpriteKitScrollingNode.app/SpriteKitScrollingNode"; 412 | FRAMEWORK_SEARCH_PATHS = ( 413 | "$(SDKROOT)/Developer/Library/Frameworks", 414 | "$(inherited)", 415 | "$(DEVELOPER_FRAMEWORKS_DIR)", 416 | ); 417 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 418 | GCC_PREFIX_HEADER = "SpriteKitScrollingNode/SpriteKitScrollingNode-Prefix.pch"; 419 | GCC_PREPROCESSOR_DEFINITIONS = ( 420 | "DEBUG=1", 421 | "$(inherited)", 422 | ); 423 | INFOPLIST_FILE = "SpriteKitScrollingNodeTests/SpriteKitScrollingNodeTests-Info.plist"; 424 | PRODUCT_NAME = "$(TARGET_NAME)"; 425 | TEST_HOST = "$(BUNDLE_LOADER)"; 426 | WRAPPER_EXTENSION = xctest; 427 | }; 428 | name = Debug; 429 | }; 430 | BD72025919832DCE00DB4AB1 /* Release */ = { 431 | isa = XCBuildConfiguration; 432 | buildSettings = { 433 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SpriteKitScrollingNode.app/SpriteKitScrollingNode"; 434 | FRAMEWORK_SEARCH_PATHS = ( 435 | "$(SDKROOT)/Developer/Library/Frameworks", 436 | "$(inherited)", 437 | "$(DEVELOPER_FRAMEWORKS_DIR)", 438 | ); 439 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 440 | GCC_PREFIX_HEADER = "SpriteKitScrollingNode/SpriteKitScrollingNode-Prefix.pch"; 441 | INFOPLIST_FILE = "SpriteKitScrollingNodeTests/SpriteKitScrollingNodeTests-Info.plist"; 442 | PRODUCT_NAME = "$(TARGET_NAME)"; 443 | TEST_HOST = "$(BUNDLE_LOADER)"; 444 | WRAPPER_EXTENSION = xctest; 445 | }; 446 | name = Release; 447 | }; 448 | /* End XCBuildConfiguration section */ 449 | 450 | /* Begin XCConfigurationList section */ 451 | BD72022319832DCE00DB4AB1 /* Build configuration list for PBXProject "SpriteKitScrollingNode" */ = { 452 | isa = XCConfigurationList; 453 | buildConfigurations = ( 454 | BD72025219832DCE00DB4AB1 /* Debug */, 455 | BD72025319832DCE00DB4AB1 /* Release */, 456 | ); 457 | defaultConfigurationIsVisible = 0; 458 | defaultConfigurationName = Release; 459 | }; 460 | BD72025419832DCE00DB4AB1 /* Build configuration list for PBXNativeTarget "SpriteKitScrollingNode" */ = { 461 | isa = XCConfigurationList; 462 | buildConfigurations = ( 463 | BD72025519832DCE00DB4AB1 /* Debug */, 464 | BD72025619832DCE00DB4AB1 /* Release */, 465 | ); 466 | defaultConfigurationIsVisible = 0; 467 | defaultConfigurationName = Release; 468 | }; 469 | BD72025719832DCE00DB4AB1 /* Build configuration list for PBXNativeTarget "SpriteKitScrollingNodeTests" */ = { 470 | isa = XCConfigurationList; 471 | buildConfigurations = ( 472 | BD72025819832DCE00DB4AB1 /* Debug */, 473 | BD72025919832DCE00DB4AB1 /* Release */, 474 | ); 475 | defaultConfigurationIsVisible = 0; 476 | defaultConfigurationName = Release; 477 | }; 478 | /* End XCConfigurationList section */ 479 | }; 480 | rootObject = BD72022019832DCE00DB4AB1 /* Project object */; 481 | } 482 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode.xcodeproj/xcuserdata/Jen.xcuserdatad/xcschemes/SpriteKitScrollingNode.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode.xcodeproj/xcuserdata/Jen.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SpriteKitScrollingNode.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | BD72022719832DCE00DB4AB1 16 | 17 | primary 18 | 19 | 20 | BD72024219832DCE00DB4AB1 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "ipad", 5 | "size" : "29x29", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "ipad", 10 | "size" : "29x29", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "ipad", 15 | "size" : "40x40", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "40x40", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "76x76", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "76x76", 31 | "scale" : "2x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /SpriteKitScrollingNode/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "ipad", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "1x" 9 | }, 10 | { 11 | "orientation" : "landscape", 12 | "idiom" : "ipad", 13 | "extent" : "full-screen", 14 | "minimum-system-version" : "7.0", 15 | "scale" : "1x" 16 | }, 17 | { 18 | "orientation" : "portrait", 19 | "idiom" : "ipad", 20 | "extent" : "full-screen", 21 | "minimum-system-version" : "7.0", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "orientation" : "landscape", 26 | "idiom" : "ipad", 27 | "extent" : "full-screen", 28 | "minimum-system-version" : "7.0", 29 | "scale" : "2x" 30 | } 31 | ], 32 | "info" : { 33 | "version" : 1, 34 | "author" : "xcode" 35 | } 36 | } -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // JADAppDelegate.h 3 | // SpriteKitScrollingNode 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JADAppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // JADAppDelegate.m 3 | // SpriteKitScrollingNode 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import "JADAppDelegate.h" 10 | #import "JADViewController.h" 11 | 12 | @implementation JADAppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 17 | // Override point for customization after application launch. 18 | self.window.backgroundColor = [UIColor whiteColor]; 19 | [self.window makeKeyAndVisible]; 20 | 21 | JADViewController *vc = [[JADViewController alloc] init]; 22 | 23 | _window.rootViewController = vc; 24 | 25 | 26 | 27 | 28 | return YES; 29 | } 30 | 31 | - (void)applicationWillResignActive:(UIApplication *)application 32 | { 33 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 34 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 35 | } 36 | 37 | - (void)applicationDidEnterBackground:(UIApplication *)application 38 | { 39 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 40 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 41 | } 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application 44 | { 45 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 46 | } 47 | 48 | - (void)applicationDidBecomeActive:(UIApplication *)application 49 | { 50 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 51 | } 52 | 53 | - (void)applicationWillTerminate:(UIApplication *)application 54 | { 55 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADMainScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // JADMainScene.h 3 | // SpriteKitScrollingNode 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import 10 | @class JADViewController; 11 | 12 | @interface JADMainScene : SKScene 13 | 14 | @property (nonatomic, weak) JADViewController* viewController; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADMainScene.m: -------------------------------------------------------------------------------- 1 | // 2 | // JADMainScene.m 3 | // SpriteKitScrollingNode 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import "JADMainScene.h" 10 | #import "JADSKScrollingNode.h" 11 | #import "JADViewController.h" 12 | 13 | 14 | @interface JADMainScene() 15 | 16 | @property (nonatomic, strong) JADSKScrollingNode* scrollingNode; 17 | 18 | @end 19 | 20 | @implementation JADMainScene 21 | 22 | -(id)initWithSize:(CGSize)size { 23 | if (self = [super initWithSize:size]) { 24 | 25 | _scrollingNode = [[JADSKScrollingNode alloc] initWithSize:size]; 26 | _scrollingNode.position = CGPointMake(0, 0); 27 | 28 | [self addChild:_scrollingNode]; 29 | 30 | SKLabelNode *topLabelNode = [[SKLabelNode alloc] init]; 31 | topLabelNode.text = @"Top"; 32 | topLabelNode.position = CGPointMake(50, 2000-50); 33 | 34 | SKLabelNode *bottomLabelNode = [[SKLabelNode alloc] init]; 35 | bottomLabelNode.text = @"Bottom"; 36 | bottomLabelNode.position = CGPointMake(50, 50); 37 | 38 | SKSpriteNode *node1 = [[SKSpriteNode alloc] initWithColor:[UIColor redColor] size:CGSizeMake(800, 450)]; 39 | SKSpriteNode *node2 = [node1 copy]; 40 | SKSpriteNode *node3 = [node1 copy]; 41 | 42 | 43 | node1.position = CGPointMake(512, 500); 44 | node2.position = CGPointMake(512, 1000); 45 | node3.position = CGPointMake(512, 1500); 46 | 47 | [_scrollingNode addChild:topLabelNode]; 48 | [_scrollingNode addChild:bottomLabelNode]; 49 | [_scrollingNode addChild:node1]; 50 | [_scrollingNode addChild:node2]; 51 | [_scrollingNode addChild:node3]; 52 | 53 | 54 | 55 | SKLabelNode* otherSceneNode = [SKLabelNode node]; 56 | otherSceneNode.text = @"Switch To Part Scrolling Scene"; 57 | otherSceneNode.name = @"OtherSceneNode"; 58 | otherSceneNode.position = (CGPoint){800,100}; 59 | [self addChild:otherSceneNode]; 60 | 61 | } 62 | return self; 63 | } 64 | 65 | -(void)didMoveToView:(SKView *)view 66 | { 67 | 68 | [_scrollingNode enableScrollingOnView:view]; 69 | [_scrollingNode scrollToTop]; 70 | 71 | } 72 | 73 | -(void)willMoveFromView:(SKView *)view 74 | { 75 | [_scrollingNode disableScrollingOnView:view]; 76 | } 77 | 78 | -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 79 | { 80 | UITouch *touch = [touches anyObject]; 81 | CGPoint location = [touch locationInNode:self]; 82 | SKNode *touchedNode = [self nodeAtPoint:location]; 83 | NSString* nodeName = touchedNode.name; 84 | if ([touchedNode isKindOfClass:[SKSpriteNode class]]) { 85 | SKAction *blueAction = [SKAction colorizeWithColor:[UIColor blueColor] colorBlendFactor:1 duration:.5]; 86 | SKAction *redAction = [SKAction colorizeWithColor:[UIColor redColor] colorBlendFactor:1 duration:.5]; 87 | [touchedNode runAction:[SKAction sequence:@[blueAction,redAction]]]; 88 | } 89 | else if ([nodeName isEqualToString:@"OtherSceneNode"]) 90 | [self.viewController presentPartScrollingScene]; 91 | 92 | } 93 | @end 94 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADPartScrollingScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // JADPartScrollingScene.h 3 | // SpriteKitScrollingNode 4 | // 5 | // Created by Jennifer Dobson on 8/16/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import 10 | @class JADViewController; 11 | 12 | @interface JADPartScrollingScene : SKScene 13 | 14 | @property (nonatomic, weak) JADViewController* viewController; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADPartScrollingScene.m: -------------------------------------------------------------------------------- 1 | // 2 | // JADPartScrollingScene.m 3 | // SpriteKitScrollingNode 4 | // 5 | // Created by Jennifer Dobson on 8/16/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import "JADPartScrollingScene.h" 10 | #import "JADSKScrollingNode.h" 11 | #import "JADViewController.h" 12 | 13 | @interface JADPartScrollingScene() 14 | 15 | @property (nonatomic, strong) JADSKScrollingNode* scrollingNode; 16 | 17 | @end 18 | 19 | 20 | static const CGFloat kScrollingNodeXPosition = 300; 21 | static const CGFloat kScrollingNodeYPosition = 300; 22 | static const CGFloat kScrollingNodeWidth = 300; 23 | static const CGFloat kScrollingNodeHeight = 300; 24 | 25 | 26 | 27 | @implementation JADPartScrollingScene 28 | 29 | -(id)initWithSize:(CGSize)size { 30 | if (self = [super initWithSize:size]) { 31 | 32 | 33 | SKSpriteNode *rectNode = [[SKSpriteNode alloc] initWithColor:[SKColor greenColor] size:(CGSize){kScrollingNodeWidth,kScrollingNodeHeight}]; 34 | rectNode.position = (CGPoint){kScrollingNodeXPosition,kScrollingNodeYPosition}; 35 | 36 | SKSpriteNode *maskNode = [rectNode copy]; 37 | 38 | SKCropNode* cropNode = [SKCropNode node]; 39 | cropNode.maskNode = maskNode; 40 | [cropNode addChild:rectNode]; 41 | 42 | _scrollingNode = [[JADSKScrollingNode alloc] initWithSize:(CGSize){kScrollingNodeWidth,kScrollingNodeHeight}]; 43 | _scrollingNode.position = CGPointMake(kScrollingNodeXPosition, kScrollingNodeYPosition); 44 | 45 | [rectNode addChild:_scrollingNode]; 46 | [self addChild:cropNode]; 47 | 48 | SKLabelNode *topLabelNode = [[SKLabelNode alloc] init]; 49 | topLabelNode.text = @"Top"; 50 | topLabelNode.position = CGPointMake(0, 500-50); 51 | 52 | SKLabelNode *bottomLabelNode = [[SKLabelNode alloc] init]; 53 | bottomLabelNode.text = @"Bottom"; 54 | bottomLabelNode.position = CGPointMake(0, 50); 55 | 56 | SKSpriteNode *node1 = [[SKSpriteNode alloc] initWithColor:[UIColor redColor] size:CGSizeMake(100, 100)]; 57 | SKSpriteNode *node2 = [node1 copy]; 58 | SKSpriteNode *node3 = [node1 copy]; 59 | 60 | 61 | node1.position = CGPointMake(0, 150); 62 | node2.position = CGPointMake(0, 260); 63 | node3.position = CGPointMake(0, 370); 64 | 65 | [_scrollingNode addChild:topLabelNode]; 66 | [_scrollingNode addChild:bottomLabelNode]; 67 | [_scrollingNode addChild:node1]; 68 | [_scrollingNode addChild:node2]; 69 | [_scrollingNode addChild:node3]; 70 | 71 | 72 | SKLabelNode* otherSceneNode = [SKLabelNode node]; 73 | otherSceneNode.text = @"Switch To Full Scrolling Scene"; 74 | otherSceneNode.name = @"OtherSceneNode"; 75 | otherSceneNode.position = (CGPoint){800,100}; 76 | [self addChild:otherSceneNode]; 77 | } 78 | return self; 79 | } 80 | 81 | 82 | -(void)didMoveToView:(SKView *)view 83 | { 84 | 85 | [_scrollingNode enableScrollingOnView:view]; 86 | [_scrollingNode scrollToTop]; 87 | 88 | } 89 | 90 | -(void)willMoveFromView:(SKView *)view 91 | { 92 | [_scrollingNode disableScrollingOnView:view]; 93 | } 94 | 95 | 96 | -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 97 | { 98 | UITouch *touch = [touches anyObject]; 99 | CGPoint location = [touch locationInNode:self]; 100 | SKNode *touchedNode = [self nodeAtPoint:location]; 101 | NSString* nodeName = touchedNode.name; 102 | 103 | if ([nodeName isEqualToString:@"OtherSceneNode"]) 104 | [self.viewController presentFullScrollingScene]; 105 | 106 | 107 | } 108 | 109 | @end 110 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADSKScrollingNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // JADSKScrollingNode.h 3 | // FirstLetters 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //@interface JADSKScrollingNode : SKCropNode 12 | @interface JADSKScrollingNode : SKNode 13 | 14 | 15 | @property (nonatomic) CGSize size; 16 | 17 | -(id)initWithSize:(CGSize)size; 18 | -(void)scrollToTop; 19 | -(void)scrollToBottom; 20 | -(void)enableScrollingOnView:(UIView*)view; 21 | -(void)disableScrollingOnView:(UIView*)view; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADSKScrollingNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // JADSKScrollingNode.m 3 | // FirstLetters 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import "JADSKScrollingNode.h" 10 | 11 | 12 | @interface JADSKScrollingNode() 13 | 14 | @property (nonatomic) CGFloat minYPosition; 15 | @property (nonatomic) CGFloat maxYPosition; 16 | @property (nonatomic, strong) UIPanGestureRecognizer *gestureRecognizer; 17 | @property (nonatomic) CGFloat yOffset; 18 | 19 | @end 20 | 21 | 22 | static const CGFloat kScrollDuration = .3; 23 | 24 | @implementation JADSKScrollingNode 25 | 26 | -(id)initWithSize:(CGSize)size 27 | { 28 | self = [super init]; 29 | 30 | if (self) 31 | { 32 | _size = size; 33 | _yOffset = [self calculateAccumulatedFrame].origin.y; 34 | 35 | } 36 | return self; 37 | 38 | } 39 | 40 | -(void)addChild:(SKNode *)node 41 | { 42 | [super addChild:node]; 43 | _yOffset = [self calculateAccumulatedFrame].origin.y; 44 | } 45 | 46 | 47 | -(CGFloat) minYPosition 48 | { 49 | CGSize parentSize = self.parent.frame.size; 50 | 51 | 52 | CGFloat minPosition =(parentSize.height - [self calculateAccumulatedFrame].size.height - _yOffset); 53 | 54 | return minPosition; 55 | 56 | 57 | } 58 | 59 | -(CGFloat) maxYPosition 60 | { 61 | return 0; 62 | } 63 | 64 | -(void)scrollToBottom 65 | { 66 | self.position = CGPointMake(0, self.maxYPosition); 67 | 68 | } 69 | 70 | -(void)scrollToTop 71 | { 72 | self.position = CGPointMake(0, self.minYPosition); 73 | 74 | } 75 | 76 | -(void)enableScrollingOnView:(UIView*)view 77 | { 78 | if (!_gestureRecognizer) { 79 | _gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanFrom:)]; 80 | _gestureRecognizer.delegate = self; 81 | [view addGestureRecognizer:self.gestureRecognizer]; 82 | } 83 | } 84 | 85 | -(void)disableScrollingOnView:(UIView*)view 86 | { 87 | if (_gestureRecognizer) { 88 | [view removeGestureRecognizer:_gestureRecognizer]; 89 | _gestureRecognizer = nil; 90 | } 91 | } 92 | 93 | -(void)handlePanFrom:(UIPanGestureRecognizer*)recognizer 94 | { 95 | if (recognizer.state == UIGestureRecognizerStateBegan) { 96 | 97 | 98 | } else if (recognizer.state == UIGestureRecognizerStateChanged) { 99 | 100 | CGPoint translation = [recognizer translationInView:recognizer.view]; 101 | translation = CGPointMake(translation.x, -translation.y); 102 | [self panForTranslation:translation]; 103 | [recognizer setTranslation:CGPointZero inView:recognizer.view]; 104 | 105 | } else if (recognizer.state == UIGestureRecognizerStateEnded) { 106 | 107 | CGPoint velocity = [recognizer velocityInView:recognizer.view]; 108 | CGPoint pos = self.position; 109 | CGPoint p = mult(velocity, kScrollDuration); 110 | 111 | CGPoint newPos = CGPointMake(pos.x, pos.y - p.y); 112 | newPos = [self constrainStencilNodesContainerPosition:newPos]; 113 | 114 | SKAction *moveTo = [SKAction moveTo:newPos duration:kScrollDuration]; 115 | //SKAction *moveMask = [SKAction moveTo:[self maskPositionForNodePosition:newPos] duration:kScrollDuration]; 116 | [moveTo setTimingMode:SKActionTimingEaseOut]; 117 | //[moveMask setTimingMode:SKActionTimingEaseOut]; 118 | [self runAction:moveTo]; 119 | //[self.maskNode runAction:moveMask]; 120 | 121 | } 122 | 123 | } 124 | 125 | 126 | 127 | -(void)panForTranslation:(CGPoint)translation 128 | { 129 | self.position = CGPointMake(self.position.x, self.position.y+translation.y); 130 | } 131 | 132 | - (CGPoint)constrainStencilNodesContainerPosition:(CGPoint)position { 133 | 134 | CGPoint retval = position; 135 | 136 | retval.x = self.position.x; 137 | 138 | retval.y = MAX(retval.y, self.minYPosition); 139 | retval.y = MIN(retval.y, self.maxYPosition); 140 | 141 | 142 | return retval; 143 | } 144 | 145 | 146 | CGPoint mult(const CGPoint v, const CGFloat s) { 147 | return CGPointMake(v.x*s, v.y*s); 148 | } 149 | 150 | 151 | -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch 152 | { 153 | SKNode* grandParent = self.parent.parent; 154 | 155 | if (!grandParent) { 156 | grandParent = self.parent; 157 | } 158 | CGPoint touchLocation = [touch locationInNode:grandParent]; 159 | 160 | if (!CGRectContainsPoint(self.parent.frame,touchLocation)){ 161 | return NO; 162 | } 163 | 164 | return YES; 165 | } 166 | 167 | @end 168 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // JADViewController.h 3 | // SpriteKitScrollingNode 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface JADViewController : UIViewController 12 | 13 | -(void)presentFullScrollingScene; 14 | -(void)presentPartScrollingScene; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/JADViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // JADViewController.m 3 | // SpriteKitScrollingNode 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import "JADViewController.h" 10 | #import "JADMainScene.h" 11 | #import "JADPartScrollingScene.h" 12 | 13 | #import 14 | 15 | @interface JADViewController() 16 | 17 | @property (nonatomic, strong) JADMainScene* mainScene; 18 | @property (nonatomic, strong) JADPartScrollingScene* partScrollingScreen; 19 | 20 | @end 21 | 22 | 23 | @implementation JADViewController 24 | 25 | 26 | -(void)loadView 27 | { 28 | CGRect viewFrame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width); 29 | 30 | SKView* view = [[SKView alloc] initWithFrame:viewFrame]; 31 | self.view = view; 32 | } 33 | 34 | - (void)viewDidLoad 35 | { 36 | [super viewDidLoad]; 37 | // Do any additional setup after loading the view. 38 | 39 | SKView* skView = (SKView *)self.view; 40 | skView.showsFPS = YES; 41 | skView.showsNodeCount = YES; 42 | 43 | CGSize contentSize = CGSizeMake(skView.bounds.size.width,skView.bounds.size.height); 44 | 45 | _mainScene = [JADMainScene sceneWithSize:contentSize]; 46 | _mainScene.viewController = self; 47 | _mainScene.scaleMode = SKSceneScaleModeAspectFill; 48 | 49 | _partScrollingScreen = [JADPartScrollingScene sceneWithSize:contentSize]; 50 | _partScrollingScreen.viewController = self; 51 | _partScrollingScreen.scaleMode = SKSceneScaleModeAspectFill; 52 | 53 | [self presentFullScrollingScene]; 54 | //[self presentCropDemoScene]; 55 | } 56 | 57 | 58 | -(void)presentFullScrollingScene 59 | { 60 | SKView* skView = (SKView*)self.view; 61 | [skView presentScene:_mainScene]; 62 | } 63 | -(void)presentPartScrollingScene 64 | { 65 | 66 | SKView* skView = (SKView*)self.view; 67 | [skView presentScene:_partScrollingScreen]; 68 | } 69 | 70 | - (void)didReceiveMemoryWarning 71 | { 72 | [super didReceiveMemoryWarning]; 73 | // Dispose of any resources that can be recreated. 74 | } 75 | 76 | 77 | - (BOOL)shouldAutorotate 78 | { 79 | return YES; 80 | } 81 | 82 | 83 | - (NSUInteger)supportedInterfaceOrientations 84 | { 85 | if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 86 | return UIInterfaceOrientationMaskAllButUpsideDown; 87 | } else { 88 | return UIInterfaceOrientationMaskLandscape; 89 | } 90 | } 91 | 92 | 93 | @end 94 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/SpriteKitScrollingNode-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | Jen-Dobson.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations~ipad 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationPortraitUpsideDown 35 | UIInterfaceOrientationLandscapeLeft 36 | UIInterfaceOrientationLandscapeRight 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/SpriteKitScrollingNode-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /SpriteKitScrollingNode/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SpriteKitScrollingNode 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "JADAppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([JADAppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SpriteKitScrollingNodeTests/SpriteKitScrollingNodeTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | Jen-Dobson.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SpriteKitScrollingNodeTests/SpriteKitScrollingNodeTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SpriteKitScrollingNodeTests.m 3 | // SpriteKitScrollingNodeTests 4 | // 5 | // Created by Jennifer Dobson on 7/25/14. 6 | // Copyright (c) 2014 Jennifer Dobson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SpriteKitScrollingNodeTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SpriteKitScrollingNodeTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown 24 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /SpriteKitScrollingNodeTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | --------------------------------------------------------------------------------