├── README.md ├── swiftgame.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── swiftgame.xccheckout │ └── xcuserdata │ │ └── EXIA.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── EXIA.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── swiftgame.xcscheme │ └── xcschememanagement.plist ├── swiftgame ├── AppDelegate.swift ├── Base.lproj │ └── Main.storyboard ├── GameScene.sks ├── GameScene.swift ├── GameViewController.swift ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── BGCloud.imageset │ │ ├── BGCloud.png │ │ └── Contents.json │ ├── BGCloud2.imageset │ │ ├── BGCloud2@2x.png │ │ └── Contents.json │ ├── BGGrass.imageset │ │ ├── BGGrass@2x.png │ │ └── Contents.json │ ├── BGMountains.imageset │ │ ├── BGMountains@2x.png │ │ └── Contents.json │ ├── BGSky.imageset │ │ ├── BGSky.jpg │ │ └── Contents.json │ ├── LaunchImage.launchimage │ │ └── Contents.json │ ├── Spaceship.imageset │ │ ├── Contents.json │ │ └── Spaceship.png │ └── Star.imageset │ │ ├── Contents.json │ │ └── Star.png ├── Info.plist ├── classes │ ├── parallax │ │ └── ParallaxSprite.swift │ └── utility │ │ └── CreateManager.swift └── resources │ ├── audio │ └── star.caf │ └── character.atlas │ ├── character_01.png │ ├── character_02.png │ ├── character_03.png │ ├── character_04.png │ ├── character_05.png │ ├── character_06.png │ ├── character_07.png │ ├── character_08.png │ ├── character_09.png │ ├── character_10.png │ ├── character_11.png │ ├── character_12.png │ ├── character_13.png │ └── character_14.png └── swiftgameTests ├── Info.plist └── swiftgameTests.swift /README.md: -------------------------------------------------------------------------------- 1 | SpriteKit-Swift 2 | ================ 3 | 4 | Usage 5 | --- 6 | 7 | Please __DO NOT__ use the graphic assets in any commercial projects. Use them for learning purpose only. 8 | 9 | The Swift source code of this project is __FREE__. You can redistribute and/or modify it in accordance with the terms of the accompanying __Simplified BSD__ License Agreement. 10 | 11 | Overview 12 | --- 13 | 14 | This game is built with SpriteKit using the Swift language. The game and source code highlight some of the key features in SpriteKit, but also the power the Swift language can bring. This demo should show some of the core features of SpriteKit and standard game elements used in everyday games, but also a look into the syntax and core functionality of Swift. This is a start for people to look into the Swift language and SpriteKit. 15 | 16 | Some of the features & highlights this game showcases: 17 | 18 | * SKSpriteNode and Textures 19 | * Parallax Background 20 | * Texture Atlas 21 | * Character Animations 22 | * Touch Tap Interaction 23 | * Tween Animations 24 | * Collision Detection 25 | * Playing sounds 26 | 27 | Features that will be coming soon: 28 | 29 | * Displaying score 30 | * Particle Effects 31 | 32 | Swift 33 | --- 34 | 35 | This project will highlight a few of the core language features about Swift, but I would read through these documents, I found them useful to learn more about Swift and understanding teh structure and syntax of the language: 36 | 37 | * [__Apple Documentation__](https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_language/index.html) 38 | * [__Download the iBook__](https://itunes.apple.com/us/book/the-swift-programming-language/id881256329?mt=11) 39 | * [__Swift Cheat Sheet__](https://github.com/grant/swift-cheat-sheet) 40 | * [__Swift Language Highlights by Matt Galloway__](http://www.raywenderlich.com/73997/swift-language-highlights) 41 | 42 | Concept, Design & Development 43 | --- 44 | 45 | [__Squid Ink Games__] (http://www.squidinkgames.com) 46 | -------------------------------------------------------------------------------- /swiftgame.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C6F0E376193E307800B6889C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6F0E375193E307800B6889C /* AppDelegate.swift */; }; 11 | C6F0E378193E307800B6889C /* GameScene.sks in Resources */ = {isa = PBXBuildFile; fileRef = C6F0E377193E307800B6889C /* GameScene.sks */; }; 12 | C6F0E37A193E307800B6889C /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6F0E379193E307800B6889C /* GameScene.swift */; }; 13 | C6F0E37C193E307800B6889C /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6F0E37B193E307800B6889C /* GameViewController.swift */; }; 14 | C6F0E37F193E307800B6889C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C6F0E37D193E307800B6889C /* Main.storyboard */; }; 15 | C6F0E381193E307800B6889C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C6F0E380193E307800B6889C /* Images.xcassets */; }; 16 | C6F0E38D193E307800B6889C /* swiftgameTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6F0E38C193E307800B6889C /* swiftgameTests.swift */; }; 17 | C6F0E3BA193E317000B6889C /* ParallaxSprite.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6F0E3B9193E317000B6889C /* ParallaxSprite.swift */; }; 18 | C6F0E414193E996000B6889C /* star.caf in Resources */ = {isa = PBXBuildFile; fileRef = C6F0E40B193E996000B6889C /* star.caf */; }; 19 | C6F0E415193E996000B6889C /* character.atlas in Resources */ = {isa = PBXBuildFile; fileRef = C6F0E40C193E996000B6889C /* character.atlas */; }; 20 | C6F0E440193F234600B6889C /* CreateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6F0E43F193F234600B6889C /* CreateManager.swift */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | C6F0E387193E307800B6889C /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = C6F0E368193E307800B6889C /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = C6F0E36F193E307800B6889C; 29 | remoteInfo = swiftgame; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | C6F0E370193E307800B6889C /* swiftgame.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = swiftgame.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | C6F0E374193E307800B6889C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | C6F0E375193E307800B6889C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | C6F0E377193E307800B6889C /* GameScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; name = GameScene.sks; path = swiftgame/GameScene.sks; sourceTree = ""; }; 38 | C6F0E379193E307800B6889C /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = ""; }; 39 | C6F0E37B193E307800B6889C /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = ""; }; 40 | C6F0E37E193E307800B6889C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 41 | C6F0E380193E307800B6889C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = swiftgame/Images.xcassets; sourceTree = ""; }; 42 | C6F0E386193E307800B6889C /* swiftgameTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = swiftgameTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | C6F0E38B193E307800B6889C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | C6F0E38C193E307800B6889C /* swiftgameTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = swiftgameTests.swift; sourceTree = ""; }; 45 | C6F0E3B9193E317000B6889C /* ParallaxSprite.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ParallaxSprite.swift; path = classes/parallax/ParallaxSprite.swift; sourceTree = ""; }; 46 | C6F0E40B193E996000B6889C /* star.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = star.caf; sourceTree = ""; }; 47 | C6F0E40C193E996000B6889C /* character.atlas */ = {isa = PBXFileReference; lastKnownFileType = folder.skatlas; path = character.atlas; sourceTree = ""; }; 48 | C6F0E43F193F234600B6889C /* CreateManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CreateManager.swift; path = classes/utility/CreateManager.swift; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | C6F0E36D193E307800B6889C /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | C6F0E383193E307800B6889C /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | C6F0E367193E307800B6889C = { 70 | isa = PBXGroup; 71 | children = ( 72 | C6F0E409193E996000B6889C /* resources */, 73 | C6F0E3B6193E308F00B6889C /* support */, 74 | C6F0E372193E307800B6889C /* swiftgame */, 75 | C6F0E389193E307800B6889C /* swiftgameTests */, 76 | C6F0E371193E307800B6889C /* Products */, 77 | ); 78 | sourceTree = ""; 79 | }; 80 | C6F0E371193E307800B6889C /* Products */ = { 81 | isa = PBXGroup; 82 | children = ( 83 | C6F0E370193E307800B6889C /* swiftgame.app */, 84 | C6F0E386193E307800B6889C /* swiftgameTests.xctest */, 85 | ); 86 | name = Products; 87 | sourceTree = ""; 88 | }; 89 | C6F0E372193E307800B6889C /* swiftgame */ = { 90 | isa = PBXGroup; 91 | children = ( 92 | C6F0E43E193F231700B6889C /* utility */, 93 | C6F0E3B7193E311400B6889C /* parallax */, 94 | C6F0E375193E307800B6889C /* AppDelegate.swift */, 95 | C6F0E379193E307800B6889C /* GameScene.swift */, 96 | C6F0E37B193E307800B6889C /* GameViewController.swift */, 97 | ); 98 | path = swiftgame; 99 | sourceTree = ""; 100 | }; 101 | C6F0E373193E307800B6889C /* Supporting Files */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | C6F0E374193E307800B6889C /* Info.plist */, 105 | ); 106 | name = "Supporting Files"; 107 | path = swiftgame; 108 | sourceTree = ""; 109 | }; 110 | C6F0E389193E307800B6889C /* swiftgameTests */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | C6F0E38C193E307800B6889C /* swiftgameTests.swift */, 114 | C6F0E38A193E307800B6889C /* Supporting Files */, 115 | ); 116 | path = swiftgameTests; 117 | sourceTree = ""; 118 | }; 119 | C6F0E38A193E307800B6889C /* Supporting Files */ = { 120 | isa = PBXGroup; 121 | children = ( 122 | C6F0E38B193E307800B6889C /* Info.plist */, 123 | ); 124 | name = "Supporting Files"; 125 | sourceTree = ""; 126 | }; 127 | C6F0E3B6193E308F00B6889C /* support */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | C6F0E377193E307800B6889C /* GameScene.sks */, 131 | C6F0E37D193E307800B6889C /* Main.storyboard */, 132 | C6F0E380193E307800B6889C /* Images.xcassets */, 133 | C6F0E373193E307800B6889C /* Supporting Files */, 134 | ); 135 | name = support; 136 | sourceTree = ""; 137 | }; 138 | C6F0E3B7193E311400B6889C /* parallax */ = { 139 | isa = PBXGroup; 140 | children = ( 141 | C6F0E3B9193E317000B6889C /* ParallaxSprite.swift */, 142 | ); 143 | name = parallax; 144 | sourceTree = ""; 145 | }; 146 | C6F0E409193E996000B6889C /* resources */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | C6F0E40A193E996000B6889C /* audio */, 150 | C6F0E40C193E996000B6889C /* character.atlas */, 151 | ); 152 | name = resources; 153 | path = swiftgame/resources; 154 | sourceTree = ""; 155 | }; 156 | C6F0E40A193E996000B6889C /* audio */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | C6F0E40B193E996000B6889C /* star.caf */, 160 | ); 161 | path = audio; 162 | sourceTree = ""; 163 | }; 164 | C6F0E43E193F231700B6889C /* utility */ = { 165 | isa = PBXGroup; 166 | children = ( 167 | C6F0E43F193F234600B6889C /* CreateManager.swift */, 168 | ); 169 | name = utility; 170 | sourceTree = ""; 171 | }; 172 | /* End PBXGroup section */ 173 | 174 | /* Begin PBXNativeTarget section */ 175 | C6F0E36F193E307800B6889C /* swiftgame */ = { 176 | isa = PBXNativeTarget; 177 | buildConfigurationList = C6F0E390193E307800B6889C /* Build configuration list for PBXNativeTarget "swiftgame" */; 178 | buildPhases = ( 179 | C6F0E36C193E307800B6889C /* Sources */, 180 | C6F0E36D193E307800B6889C /* Frameworks */, 181 | C6F0E36E193E307800B6889C /* Resources */, 182 | ); 183 | buildRules = ( 184 | ); 185 | dependencies = ( 186 | ); 187 | name = swiftgame; 188 | productName = swiftgame; 189 | productReference = C6F0E370193E307800B6889C /* swiftgame.app */; 190 | productType = "com.apple.product-type.application"; 191 | }; 192 | C6F0E385193E307800B6889C /* swiftgameTests */ = { 193 | isa = PBXNativeTarget; 194 | buildConfigurationList = C6F0E393193E307800B6889C /* Build configuration list for PBXNativeTarget "swiftgameTests" */; 195 | buildPhases = ( 196 | C6F0E382193E307800B6889C /* Sources */, 197 | C6F0E383193E307800B6889C /* Frameworks */, 198 | C6F0E384193E307800B6889C /* Resources */, 199 | ); 200 | buildRules = ( 201 | ); 202 | dependencies = ( 203 | C6F0E388193E307800B6889C /* PBXTargetDependency */, 204 | ); 205 | name = swiftgameTests; 206 | productName = swiftgameTests; 207 | productReference = C6F0E386193E307800B6889C /* swiftgameTests.xctest */; 208 | productType = "com.apple.product-type.bundle.unit-test"; 209 | }; 210 | /* End PBXNativeTarget section */ 211 | 212 | /* Begin PBXProject section */ 213 | C6F0E368193E307800B6889C /* Project object */ = { 214 | isa = PBXProject; 215 | attributes = { 216 | LastUpgradeCheck = 0600; 217 | ORGANIZATIONNAME = "Squid Ink Games"; 218 | TargetAttributes = { 219 | C6F0E36F193E307800B6889C = { 220 | CreatedOnToolsVersion = 6.0; 221 | }; 222 | C6F0E385193E307800B6889C = { 223 | CreatedOnToolsVersion = 6.0; 224 | TestTargetID = C6F0E36F193E307800B6889C; 225 | }; 226 | }; 227 | }; 228 | buildConfigurationList = C6F0E36B193E307800B6889C /* Build configuration list for PBXProject "swiftgame" */; 229 | compatibilityVersion = "Xcode 3.2"; 230 | developmentRegion = English; 231 | hasScannedForEncodings = 0; 232 | knownRegions = ( 233 | en, 234 | Base, 235 | ); 236 | mainGroup = C6F0E367193E307800B6889C; 237 | productRefGroup = C6F0E371193E307800B6889C /* Products */; 238 | projectDirPath = ""; 239 | projectRoot = ""; 240 | targets = ( 241 | C6F0E36F193E307800B6889C /* swiftgame */, 242 | C6F0E385193E307800B6889C /* swiftgameTests */, 243 | ); 244 | }; 245 | /* End PBXProject section */ 246 | 247 | /* Begin PBXResourcesBuildPhase section */ 248 | C6F0E36E193E307800B6889C /* Resources */ = { 249 | isa = PBXResourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | C6F0E381193E307800B6889C /* Images.xcassets in Resources */, 253 | C6F0E415193E996000B6889C /* character.atlas in Resources */, 254 | C6F0E378193E307800B6889C /* GameScene.sks in Resources */, 255 | C6F0E414193E996000B6889C /* star.caf in Resources */, 256 | C6F0E37F193E307800B6889C /* Main.storyboard in Resources */, 257 | ); 258 | runOnlyForDeploymentPostprocessing = 0; 259 | }; 260 | C6F0E384193E307800B6889C /* Resources */ = { 261 | isa = PBXResourcesBuildPhase; 262 | buildActionMask = 2147483647; 263 | files = ( 264 | ); 265 | runOnlyForDeploymentPostprocessing = 0; 266 | }; 267 | /* End PBXResourcesBuildPhase section */ 268 | 269 | /* Begin PBXSourcesBuildPhase section */ 270 | C6F0E36C193E307800B6889C /* Sources */ = { 271 | isa = PBXSourcesBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | C6F0E440193F234600B6889C /* CreateManager.swift in Sources */, 275 | C6F0E37A193E307800B6889C /* GameScene.swift in Sources */, 276 | C6F0E37C193E307800B6889C /* GameViewController.swift in Sources */, 277 | C6F0E376193E307800B6889C /* AppDelegate.swift in Sources */, 278 | C6F0E3BA193E317000B6889C /* ParallaxSprite.swift in Sources */, 279 | ); 280 | runOnlyForDeploymentPostprocessing = 0; 281 | }; 282 | C6F0E382193E307800B6889C /* Sources */ = { 283 | isa = PBXSourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | C6F0E38D193E307800B6889C /* swiftgameTests.swift in Sources */, 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | /* End PBXSourcesBuildPhase section */ 291 | 292 | /* Begin PBXTargetDependency section */ 293 | C6F0E388193E307800B6889C /* PBXTargetDependency */ = { 294 | isa = PBXTargetDependency; 295 | target = C6F0E36F193E307800B6889C /* swiftgame */; 296 | targetProxy = C6F0E387193E307800B6889C /* PBXContainerItemProxy */; 297 | }; 298 | /* End PBXTargetDependency section */ 299 | 300 | /* Begin PBXVariantGroup section */ 301 | C6F0E37D193E307800B6889C /* Main.storyboard */ = { 302 | isa = PBXVariantGroup; 303 | children = ( 304 | C6F0E37E193E307800B6889C /* Base */, 305 | ); 306 | name = Main.storyboard; 307 | path = swiftgame; 308 | sourceTree = ""; 309 | }; 310 | /* End PBXVariantGroup section */ 311 | 312 | /* Begin XCBuildConfiguration section */ 313 | C6F0E38E193E307800B6889C /* Debug */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | ALWAYS_SEARCH_USER_PATHS = NO; 317 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 318 | CLANG_CXX_LIBRARY = "libc++"; 319 | CLANG_ENABLE_MODULES = YES; 320 | CLANG_ENABLE_OBJC_ARC = YES; 321 | CLANG_WARN_BOOL_CONVERSION = YES; 322 | CLANG_WARN_CONSTANT_CONVERSION = YES; 323 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 324 | CLANG_WARN_EMPTY_BODY = YES; 325 | CLANG_WARN_ENUM_CONVERSION = YES; 326 | CLANG_WARN_INT_CONVERSION = YES; 327 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 328 | CLANG_WARN_UNREACHABLE_CODE = YES; 329 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 330 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 331 | COPY_PHASE_STRIP = NO; 332 | ENABLE_STRICT_OBJC_MSGSEND = YES; 333 | GCC_C_LANGUAGE_STANDARD = gnu99; 334 | GCC_DYNAMIC_NO_PIC = NO; 335 | GCC_OPTIMIZATION_LEVEL = 0; 336 | GCC_PREPROCESSOR_DEFINITIONS = ( 337 | "DEBUG=1", 338 | "$(inherited)", 339 | ); 340 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 341 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 342 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 343 | GCC_WARN_UNDECLARED_SELECTOR = YES; 344 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 345 | GCC_WARN_UNUSED_FUNCTION = YES; 346 | GCC_WARN_UNUSED_VARIABLE = YES; 347 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 348 | METAL_ENABLE_DEBUG_INFO = YES; 349 | ONLY_ACTIVE_ARCH = YES; 350 | SDKROOT = iphoneos; 351 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 352 | }; 353 | name = Debug; 354 | }; 355 | C6F0E38F193E307800B6889C /* Release */ = { 356 | isa = XCBuildConfiguration; 357 | buildSettings = { 358 | ALWAYS_SEARCH_USER_PATHS = NO; 359 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 360 | CLANG_CXX_LIBRARY = "libc++"; 361 | CLANG_ENABLE_MODULES = YES; 362 | CLANG_ENABLE_OBJC_ARC = YES; 363 | CLANG_WARN_BOOL_CONVERSION = YES; 364 | CLANG_WARN_CONSTANT_CONVERSION = YES; 365 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 366 | CLANG_WARN_EMPTY_BODY = YES; 367 | CLANG_WARN_ENUM_CONVERSION = YES; 368 | CLANG_WARN_INT_CONVERSION = YES; 369 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 370 | CLANG_WARN_UNREACHABLE_CODE = YES; 371 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 372 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 373 | COPY_PHASE_STRIP = YES; 374 | ENABLE_NS_ASSERTIONS = NO; 375 | ENABLE_STRICT_OBJC_MSGSEND = YES; 376 | GCC_C_LANGUAGE_STANDARD = gnu99; 377 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 378 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 379 | GCC_WARN_UNDECLARED_SELECTOR = YES; 380 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 381 | GCC_WARN_UNUSED_FUNCTION = YES; 382 | GCC_WARN_UNUSED_VARIABLE = YES; 383 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 384 | METAL_ENABLE_DEBUG_INFO = NO; 385 | SDKROOT = iphoneos; 386 | VALIDATE_PRODUCT = YES; 387 | }; 388 | name = Release; 389 | }; 390 | C6F0E391193E307800B6889C /* Debug */ = { 391 | isa = XCBuildConfiguration; 392 | buildSettings = { 393 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 394 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 395 | INFOPLIST_FILE = swiftgame/Info.plist; 396 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 397 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 398 | PRODUCT_NAME = "$(TARGET_NAME)"; 399 | }; 400 | name = Debug; 401 | }; 402 | C6F0E392193E307800B6889C /* Release */ = { 403 | isa = XCBuildConfiguration; 404 | buildSettings = { 405 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 406 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 407 | INFOPLIST_FILE = swiftgame/Info.plist; 408 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 409 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 410 | PRODUCT_NAME = "$(TARGET_NAME)"; 411 | }; 412 | name = Release; 413 | }; 414 | C6F0E394193E307800B6889C /* Debug */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/swiftgame.app/swiftgame"; 418 | FRAMEWORK_SEARCH_PATHS = ( 419 | "$(SDKROOT)/Developer/Library/Frameworks", 420 | "$(inherited)", 421 | ); 422 | GCC_PREPROCESSOR_DEFINITIONS = ( 423 | "DEBUG=1", 424 | "$(inherited)", 425 | ); 426 | INFOPLIST_FILE = swiftgameTests/Info.plist; 427 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 428 | METAL_ENABLE_DEBUG_INFO = YES; 429 | PRODUCT_NAME = "$(TARGET_NAME)"; 430 | TEST_HOST = "$(BUNDLE_LOADER)"; 431 | }; 432 | name = Debug; 433 | }; 434 | C6F0E395193E307800B6889C /* Release */ = { 435 | isa = XCBuildConfiguration; 436 | buildSettings = { 437 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/swiftgame.app/swiftgame"; 438 | FRAMEWORK_SEARCH_PATHS = ( 439 | "$(SDKROOT)/Developer/Library/Frameworks", 440 | "$(inherited)", 441 | ); 442 | INFOPLIST_FILE = swiftgameTests/Info.plist; 443 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 444 | METAL_ENABLE_DEBUG_INFO = NO; 445 | PRODUCT_NAME = "$(TARGET_NAME)"; 446 | TEST_HOST = "$(BUNDLE_LOADER)"; 447 | }; 448 | name = Release; 449 | }; 450 | /* End XCBuildConfiguration section */ 451 | 452 | /* Begin XCConfigurationList section */ 453 | C6F0E36B193E307800B6889C /* Build configuration list for PBXProject "swiftgame" */ = { 454 | isa = XCConfigurationList; 455 | buildConfigurations = ( 456 | C6F0E38E193E307800B6889C /* Debug */, 457 | C6F0E38F193E307800B6889C /* Release */, 458 | ); 459 | defaultConfigurationIsVisible = 0; 460 | defaultConfigurationName = Release; 461 | }; 462 | C6F0E390193E307800B6889C /* Build configuration list for PBXNativeTarget "swiftgame" */ = { 463 | isa = XCConfigurationList; 464 | buildConfigurations = ( 465 | C6F0E391193E307800B6889C /* Debug */, 466 | C6F0E392193E307800B6889C /* Release */, 467 | ); 468 | defaultConfigurationIsVisible = 0; 469 | }; 470 | C6F0E393193E307800B6889C /* Build configuration list for PBXNativeTarget "swiftgameTests" */ = { 471 | isa = XCConfigurationList; 472 | buildConfigurations = ( 473 | C6F0E394193E307800B6889C /* Debug */, 474 | C6F0E395193E307800B6889C /* Release */, 475 | ); 476 | defaultConfigurationIsVisible = 0; 477 | }; 478 | /* End XCConfigurationList section */ 479 | }; 480 | rootObject = C6F0E368193E307800B6889C /* Project object */; 481 | } 482 | -------------------------------------------------------------------------------- /swiftgame.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /swiftgame.xcodeproj/project.xcworkspace/xcshareddata/swiftgame.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 74F3F6C1-908D-4454-B836-0E3F5F8AF4F1 9 | IDESourceControlProjectName 10 | swiftgame 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 4E9C1C97-CCE2-41F0-8E44-A407623907B8 14 | https://github.com/stephen-squidink/SpriteKit-Swift.git 15 | 16 | IDESourceControlProjectPath 17 | swiftgame.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 4E9C1C97-CCE2-41F0-8E44-A407623907B8 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/stephen-squidink/SpriteKit-Swift.git 25 | IDESourceControlProjectVersion 26 | 110 27 | IDESourceControlProjectWCCIdentifier 28 | 4E9C1C97-CCE2-41F0-8E44-A407623907B8 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 4E9C1C97-CCE2-41F0-8E44-A407623907B8 36 | IDESourceControlWCCName 37 | SpriteKit-Swift 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /swiftgame.xcodeproj/project.xcworkspace/xcuserdata/EXIA.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame.xcodeproj/project.xcworkspace/xcuserdata/EXIA.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /swiftgame.xcodeproj/xcuserdata/EXIA.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /swiftgame.xcodeproj/xcuserdata/EXIA.xcuserdatad/xcschemes/swiftgame.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 | -------------------------------------------------------------------------------- /swiftgame.xcodeproj/xcuserdata/EXIA.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | swiftgame.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | C6F0E36F193E307800B6889C 16 | 17 | primary 18 | 19 | 20 | C6F0E385193E307800B6889C 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /swiftgame/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // swiftgame 4 | // 5 | // Created by Stephen Chan on 6/3/14. 6 | // Copyright (c) 2014 Squid Ink Games. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /swiftgame/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /swiftgame/GameScene.sks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/GameScene.sks -------------------------------------------------------------------------------- /swiftgame/GameScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameScene.swift 3 | // swiftgame 4 | // 5 | // Created by Stephen Chan on 6/3/14. 6 | // Copyright (c) 2014 Squid Ink Games. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import SpriteKit 11 | 12 | struct ContactCategory { 13 | static let charactor : UInt32 = 0x1 << 0; 14 | static let star : UInt32 = 0x1 << 1; 15 | } 16 | 17 | class GameScene: SKScene, SKPhysicsContactDelegate { 18 | 19 | let sound : SKAction = SKAction.playSoundFileNamed("star.caf", waitForCompletion: false); 20 | 21 | var isJump : Bool = false; 22 | 23 | var background : SKSpriteNode! 24 | var parallax : [ParallaxSprite]! 25 | var player : SKSpriteNode! 26 | var stars : [SKSpriteNode] = []; 27 | 28 | var starCounter : Int = 0; 29 | 30 | override func didMoveToView(view: SKView) { 31 | let ref = CreateManager.createBackground(self); 32 | 33 | background = ref.background; 34 | parallax = ref.parallax; 35 | 36 | player = CreateManager.createCharacter(self); 37 | 38 | self.physicsWorld.contactDelegate = self; 39 | self.physicsWorld.gravity = CGVectorMake(0, 0); 40 | } 41 | 42 | override func update(currentTime: CFTimeInterval) { 43 | for p : ParallaxSprite in parallax { 44 | p.update(); 45 | } 46 | 47 | self.updateStars(); 48 | } 49 | 50 | func updateStars() { 51 | starCounter++; 52 | 53 | if(starCounter % 50 == 0){ 54 | stars.insert(CreateManager.createStar(self), atIndex: 0); 55 | } 56 | 57 | for var index = stars.count - 1; index >= 0; --index { 58 | let star : SKSpriteNode = stars[index]; 59 | star.position.x -= 10; 60 | 61 | if(star.position.x < 0 - star.size.width){ 62 | stars.removeAtIndex(index); 63 | star.removeFromParent(); 64 | } 65 | } 66 | } 67 | 68 | override func touchesBegan(touches: NSSet, withEvent event: UIEvent) { 69 | if(!isJump){ 70 | let touch : AnyObject? = touches.anyObject(); 71 | if (touch != nil) { 72 | 73 | let jumpAction : SKAction = SKAction.moveTo(CGPointMake(player.position.x, player.position.y + 200), duration: 0.3); 74 | let fallAction : SKAction = SKAction.moveTo(CGPointMake(player.position.x, CGRectGetMidY(self.frame) - 150), duration: 0.3); 75 | let completeAction : SKAction = SKAction.runBlock({ 76 | self.isJump = false; 77 | }); 78 | 79 | player.runAction(SKAction.sequence([jumpAction, fallAction, completeAction])); 80 | 81 | isJump = true; 82 | } 83 | } 84 | } 85 | 86 | func didBeginContact(contact : SKPhysicsContact){ 87 | var firstBody : SKPhysicsBody; 88 | var secondBody : SKPhysicsBody; 89 | 90 | if (contact.bodyA.categoryBitMask < contact.bodyB.categoryBitMask) { 91 | firstBody = contact.bodyA; 92 | secondBody = contact.bodyB; 93 | } else { 94 | firstBody = contact.bodyB; 95 | secondBody = contact.bodyA; 96 | } 97 | 98 | if ((firstBody.categoryBitMask & ContactCategory.star) != 0) { 99 | self.destroyStar(firstBody.node!); 100 | self.runAction(sound); 101 | } 102 | } 103 | 104 | func destroyStar(star : SKNode) { 105 | for var index = stars.count - 1; index >= 0; --index { 106 | let s : SKSpriteNode = stars[index]; 107 | 108 | if(s == star){ 109 | stars.removeAtIndex(index) 110 | star.removeFromParent(); 111 | 112 | return; 113 | } 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /swiftgame/GameViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameViewController.swift 3 | // swiftgame 4 | // 5 | // Created by Stephen Chan on 6/3/14. 6 | // Copyright (c) 2014 Squid Ink Games. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SpriteKit 11 | 12 | extension SKNode { 13 | class func unarchiveFromFile(file : NSString) -> SKNode? { 14 | 15 | let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks") 16 | 17 | var sceneData = NSData.dataWithContentsOfFile(path!, options: .DataReadingMappedIfSafe, error: nil) 18 | var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData) 19 | 20 | archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene") 21 | let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as GameScene 22 | archiver.finishDecoding() 23 | return scene 24 | } 25 | } 26 | 27 | class GameViewController: UIViewController { 28 | 29 | override func viewDidLoad() { 30 | super.viewDidLoad() 31 | 32 | if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene { 33 | // Configure the view. 34 | let skView = self.view as SKView 35 | skView.showsFPS = true 36 | skView.showsNodeCount = true 37 | 38 | /* Sprite Kit applies additional optimizations to improve rendering performance */ 39 | skView.ignoresSiblingOrder = true 40 | 41 | /* Set the scale mode to scale to fit the window */ 42 | scene.scaleMode = SKSceneScaleMode.AspectFill; 43 | 44 | skView.presentScene(scene) 45 | } 46 | } 47 | 48 | override func shouldAutorotate() -> Bool { 49 | return true 50 | } 51 | 52 | override func supportedInterfaceOrientations() -> Int { 53 | if UIDevice.currentDevice().userInterfaceIdiom == .Phone { 54 | return Int(UIInterfaceOrientationMask.AllButUpsideDown.toRaw()) 55 | } else { 56 | return Int(UIInterfaceOrientationMask.All.toRaw()) 57 | } 58 | } 59 | 60 | override func didReceiveMemoryWarning() { 61 | super.didReceiveMemoryWarning() 62 | // Release any cached data, images, etc that aren't in use. 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGCloud.imageset/BGCloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/Images.xcassets/BGCloud.imageset/BGCloud.png -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGCloud.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "BGCloud.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGCloud2.imageset/BGCloud2@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/Images.xcassets/BGCloud2.imageset/BGCloud2@2x.png -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGCloud2.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "BGCloud2@2x.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGGrass.imageset/BGGrass@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/Images.xcassets/BGGrass.imageset/BGGrass@2x.png -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGGrass.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "BGGrass@2x.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGMountains.imageset/BGMountains@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/Images.xcassets/BGMountains.imageset/BGMountains@2x.png -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGMountains.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "BGMountains@2x.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGSky.imageset/BGSky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/Images.xcassets/BGSky.imageset/BGSky.jpg -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/BGSky.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "BGSky.jpg" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/Spaceship.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "Spaceship.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/Spaceship.imageset/Spaceship.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/Images.xcassets/Spaceship.imageset/Spaceship.png -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/Star.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "Star.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | } 12 | ], 13 | "info" : { 14 | "version" : 1, 15 | "author" : "xcode" 16 | } 17 | } -------------------------------------------------------------------------------- /swiftgame/Images.xcassets/Star.imageset/Star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/Images.xcassets/Star.imageset/Star.png -------------------------------------------------------------------------------- /swiftgame/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.squidinkgames.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIStatusBarHidden 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationLandscapeLeft 36 | UIInterfaceOrientationLandscapeRight 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /swiftgame/classes/parallax/ParallaxSprite.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ParallaxSprite.swift 3 | // swiftgame 4 | // 5 | // Created by Stephen Chan on 6/3/14. 6 | // Copyright (c) 2014 Squid Ink Games. All rights reserved. 7 | // 8 | 9 | import SpriteKit 10 | 11 | class ParallaxSprite: SKSpriteNode { 12 | 13 | var parallaxSpeed : Double = 0.0; 14 | let parallaxName : String = ""; 15 | var image1 : SKSpriteNode! 16 | var image2 : SKSpriteNode! 17 | 18 | required init(coder: NSCoder) { 19 | fatalError("NSCoding not supported") 20 | } 21 | 22 | init(texture: SKTexture!) { 23 | super.init(texture: texture, color:SKColor.blackColor(), size: CGSizeMake(100, 100)); 24 | } 25 | 26 | override init(texture: SKTexture!, color: UIColor!, size: CGSize) { 27 | super.init(texture: texture, color: color, size:size) 28 | } 29 | 30 | init(name : String, speed : Double, frame: CGRect) { 31 | super.init(); 32 | 33 | self.parallaxName = name; 34 | self.parallaxSpeed = speed; 35 | 36 | let texture : SKTexture = SKTexture(imageNamed: parallaxName); 37 | 38 | self.image1 = SKSpriteNode(texture: texture, size: texture.size()); 39 | self.image1.position = CGPointMake(CGRectGetMidX(frame), CGRectGetMidY(frame)); 40 | self.addChild(image1); 41 | 42 | if(speed > 0) { 43 | self.image2 = SKSpriteNode(texture: texture); 44 | self.image2.position.x = self.image1.position.x + self.image1.size.width; 45 | self.image2.position.y = self.image1.position.y; 46 | self.addChild(self.image2); 47 | } 48 | } 49 | 50 | func update() { 51 | if(self.parallaxSpeed > 0){ 52 | self.position.x -= CGFloat(self.parallaxSpeed); 53 | 54 | if(self.position.x < -self.image1.size.width) { 55 | self.position.x = 0; 56 | } 57 | } 58 | } 59 | } 60 | 61 | -------------------------------------------------------------------------------- /swiftgame/classes/utility/CreateManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CreateManager.swift 3 | // swiftgame 4 | // 5 | // Created by Stephen Chan on 6/4/14. 6 | // Copyright (c) 2014 Squid Ink Games. All rights reserved. 7 | // 8 | 9 | import SpriteKit 10 | 11 | struct CreateManager { 12 | 13 | static func createBackground(parent : SKScene)->(background : SKSpriteNode, parallax : [ParallaxSprite]){ 14 | let background = SKSpriteNode(imageNamed: "BGSky.jpg"); 15 | background.position = CGPointMake(CGRectGetMidX(parent.frame), CGRectGetMidY(parent.frame)); 16 | 17 | parent.addChild(background); 18 | 19 | let layer1 = ParallaxSprite(name: "BGCloud", speed: 2, frame: parent.frame); 20 | let layer2 = ParallaxSprite(name: "BGMountains", speed: 3, frame: parent.frame); 21 | let layer3 = ParallaxSprite(name: "BGCloud2", speed: 4, frame: parent.frame); 22 | let layer4 = ParallaxSprite(name: "BGGrass", speed: 5, frame: parent.frame); 23 | 24 | parent.addChild(layer1); 25 | parent.addChild(layer2); 26 | parent.addChild(layer3); 27 | parent.addChild(layer4); 28 | 29 | return (background, [layer1, layer2, layer3, layer4]); 30 | } 31 | 32 | static func createCharacter(parent : SKScene)->SKSpriteNode{ 33 | let atlas : SKTextureAtlas = SKTextureAtlas(named: "character"); 34 | let f1 : SKTexture = atlas.textureNamed("character_01.png"); 35 | let f2 : SKTexture = atlas.textureNamed("character_02.png"); 36 | let f3 : SKTexture = atlas.textureNamed("character_03.png"); 37 | let f4 : SKTexture = atlas.textureNamed("character_04.png"); 38 | let f5 : SKTexture = atlas.textureNamed("character_05.png"); 39 | let f6 : SKTexture = atlas.textureNamed("character_06.png"); 40 | let f7 : SKTexture = atlas.textureNamed("character_07.png"); 41 | let f8 : SKTexture = atlas.textureNamed("character_08.png"); 42 | let f9 : SKTexture = atlas.textureNamed("character_09.png"); 43 | let f10 : SKTexture = atlas.textureNamed("character_10.png"); 44 | let f11 : SKTexture = atlas.textureNamed("character_11.png"); 45 | let f12 : SKTexture = atlas.textureNamed("character_12.png"); 46 | let f13 : SKTexture = atlas.textureNamed("character_13.png"); 47 | let f14 : SKTexture = atlas.textureNamed("character_14.png"); 48 | 49 | let characterFrames : Array = [f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13,f14]; 50 | 51 | let player : SKSpriteNode = SKSpriteNode(imageNamed: "character_01.png"); 52 | player.position = CGPointMake(CGRectGetMidX(parent.frame) - 50, CGRectGetMidY(parent.frame) - 150); 53 | 54 | parent.addChild(player); 55 | 56 | let action : SKAction = SKAction.repeatActionForever(SKAction.animateWithTextures(characterFrames, timePerFrame: 0.1)); 57 | player.runAction(action); 58 | 59 | player.physicsBody = SKPhysicsBody(rectangleOfSize: player.size); 60 | 61 | return player; 62 | } 63 | 64 | static func createStar(parent : SKScene)->SKSpriteNode{ 65 | let star : SKSpriteNode = SKSpriteNode(imageNamed: "Star"); 66 | let rnd : CGFloat = CGFloat(arc4random() % 100); 67 | star.position.x = parent.frame.width + star.size.width; 68 | star.position.y = CGFloat(CGRectGetMidY(parent.frame) - 10 + rnd); 69 | 70 | 71 | star.physicsBody = SKPhysicsBody(rectangleOfSize: star.size); 72 | star.physicsBody?.categoryBitMask = ContactCategory.star; 73 | star.physicsBody?.collisionBitMask = ContactCategory.star | ContactCategory.charactor; 74 | star.physicsBody?.contactTestBitMask = ContactCategory.star | ContactCategory.charactor; 75 | 76 | parent.addChild(star); 77 | 78 | return star; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /swiftgame/resources/audio/star.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/audio/star.caf -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_01.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_02.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_03.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_04.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_05.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_06.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_07.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_08.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_09.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_10.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_11.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_12.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_13.png -------------------------------------------------------------------------------- /swiftgame/resources/character.atlas/character_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stephen-squidink/SpriteKit-Swift/b12b2e8f49fdc59c356eac39b61c918723b8954a/swiftgame/resources/character.atlas/character_14.png -------------------------------------------------------------------------------- /swiftgameTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.squidinkgames.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /swiftgameTests/swiftgameTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // swiftgameTests.swift 3 | // swiftgameTests 4 | // 5 | // Created by Stephen Chan on 6/3/14. 6 | // Copyright (c) 2014 Squid Ink Games. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class swiftgameTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testExample() { 24 | // This is an example of a functional test case. 25 | XCTAssert(true, "Pass") 26 | } 27 | 28 | func testPerformanceExample() { 29 | // This is an example of a performance test case. 30 | self.measureBlock() { 31 | // Put the code you want to measure the time of here. 32 | } 33 | } 34 | 35 | } 36 | --------------------------------------------------------------------------------