├── .gitignore ├── README.md ├── SpriteKitSimpleGame.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── onevcat.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── onevcat.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── SpriteKitSimpleGame.xcscheme │ └── xcschememanagement.plist ├── SpriteKitSimpleGame ├── AppDelegate.h ├── AppDelegate.m ├── Base.lproj │ ├── Main_iPad.storyboard │ └── Main_iPhone.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── LaunchImage.launchimage │ │ └── Contents.json │ ├── monster.imageset │ │ ├── Contents.json │ │ ├── monster.png │ │ └── monster@2x.png │ ├── player.imageset │ │ ├── Contents.json │ │ ├── player.png │ │ └── player@2x.png │ └── projectile.imageset │ │ ├── Contents.json │ │ ├── projectile.png │ │ └── projectile@2x.png ├── MyScene.h ├── MyScene.m ├── ResultScene.h ├── ResultScene.m ├── Sounds │ ├── background-music-aac.caf │ └── pew-pew-lei.caf ├── Spaceship.png ├── SpriteKitSimpleGame-Info.plist ├── SpriteKitSimpleGame-Prefix.pch ├── ViewController.h ├── ViewController.m ├── en.lproj │ └── InfoPlist.strings └── main.m └── SpriteKitSimpleGameTests ├── SpriteKitSimpleGameTests-Info.plist ├── SpriteKitSimpleGameTests.m └── en.lproj └── InfoPlist.strings /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SpriteKitSimpleGame 2 | =================== 3 | 4 | A demo for starting using SpriteKit. Port famous Cocos2DSimpleGame to SpriteKit. 5 | 6 | See my blog for more: [SpriteKit快速入门和新时代iOS游戏开发指南](http://onevcat.com/2013/06/sprite-kit-start/) -------------------------------------------------------------------------------- /SpriteKitSimpleGame.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D17E195A176DC63F00E1878B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17E1959176DC63F00E1878B /* Foundation.framework */; }; 11 | D17E195C176DC63F00E1878B /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17E195B176DC63F00E1878B /* CoreGraphics.framework */; }; 12 | D17E195E176DC63F00E1878B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17E195D176DC63F00E1878B /* UIKit.framework */; }; 13 | D17E1960176DC63F00E1878B /* SpriteKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17E195F176DC63F00E1878B /* SpriteKit.framework */; }; 14 | D17E1966176DC63F00E1878B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D17E1964176DC63F00E1878B /* InfoPlist.strings */; }; 15 | D17E1968176DC63F00E1878B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D17E1967176DC63F00E1878B /* main.m */; }; 16 | D17E196C176DC63F00E1878B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D17E196B176DC63F00E1878B /* AppDelegate.m */; }; 17 | D17E196F176DC63F00E1878B /* Main_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D17E196D176DC63F00E1878B /* Main_iPhone.storyboard */; }; 18 | D17E1972176DC63F00E1878B /* Main_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D17E1970176DC63F00E1878B /* Main_iPad.storyboard */; }; 19 | D17E1975176DC63F00E1878B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D17E1974176DC63F00E1878B /* ViewController.m */; }; 20 | D17E1978176DC63F00E1878B /* MyScene.m in Sources */ = {isa = PBXBuildFile; fileRef = D17E1977176DC63F00E1878B /* MyScene.m */; }; 21 | D17E197A176DC63F00E1878B /* Spaceship.png in Resources */ = {isa = PBXBuildFile; fileRef = D17E1979176DC63F00E1878B /* Spaceship.png */; }; 22 | D17E197C176DC63F00E1878B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D17E197B176DC63F00E1878B /* Images.xcassets */; }; 23 | D17E1983176DC64000E1878B /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17E1982176DC64000E1878B /* XCTest.framework */; }; 24 | D17E1984176DC64000E1878B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17E1959176DC63F00E1878B /* Foundation.framework */; }; 25 | D17E1985176DC64000E1878B /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17E195D176DC63F00E1878B /* UIKit.framework */; }; 26 | D17E198D176DC64000E1878B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D17E198B176DC64000E1878B /* InfoPlist.strings */; }; 27 | D17E198F176DC64000E1878B /* SpriteKitSimpleGameTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D17E198E176DC64000E1878B /* SpriteKitSimpleGameTests.m */; }; 28 | D17E199B176DC68000E1878B /* background-music-aac.caf in Resources */ = {isa = PBXBuildFile; fileRef = D17E1999176DC68000E1878B /* background-music-aac.caf */; }; 29 | D17E199C176DC68000E1878B /* pew-pew-lei.caf in Resources */ = {isa = PBXBuildFile; fileRef = D17E199A176DC68000E1878B /* pew-pew-lei.caf */; }; 30 | D17E4CB517760ECB00B56F56 /* ResultScene.m in Sources */ = {isa = PBXBuildFile; fileRef = D17E4CB417760ECB00B56F56 /* ResultScene.m */; }; 31 | /* End PBXBuildFile section */ 32 | 33 | /* Begin PBXContainerItemProxy section */ 34 | D17E1986176DC64000E1878B /* PBXContainerItemProxy */ = { 35 | isa = PBXContainerItemProxy; 36 | containerPortal = D17E194E176DC63F00E1878B /* Project object */; 37 | proxyType = 1; 38 | remoteGlobalIDString = D17E1955176DC63F00E1878B; 39 | remoteInfo = SpriteKitSimpleGame; 40 | }; 41 | /* End PBXContainerItemProxy section */ 42 | 43 | /* Begin PBXFileReference section */ 44 | D17E1956176DC63F00E1878B /* SpriteKitSimpleGame.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SpriteKitSimpleGame.app; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | D17E1959176DC63F00E1878B /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 46 | D17E195B176DC63F00E1878B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 47 | D17E195D176DC63F00E1878B /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 48 | D17E195F176DC63F00E1878B /* SpriteKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SpriteKit.framework; path = System/Library/Frameworks/SpriteKit.framework; sourceTree = SDKROOT; }; 49 | D17E1963176DC63F00E1878B /* SpriteKitSimpleGame-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SpriteKitSimpleGame-Info.plist"; sourceTree = ""; }; 50 | D17E1965176DC63F00E1878B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 51 | D17E1967176DC63F00E1878B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 52 | D17E1969176DC63F00E1878B /* SpriteKitSimpleGame-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SpriteKitSimpleGame-Prefix.pch"; sourceTree = ""; }; 53 | D17E196A176DC63F00E1878B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 54 | D17E196B176DC63F00E1878B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 55 | D17E196E176DC63F00E1878B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPhone.storyboard; sourceTree = ""; }; 56 | D17E1971176DC63F00E1878B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main_iPad.storyboard; sourceTree = ""; }; 57 | D17E1973176DC63F00E1878B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 58 | D17E1974176DC63F00E1878B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 59 | D17E1976176DC63F00E1878B /* MyScene.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyScene.h; sourceTree = ""; }; 60 | D17E1977176DC63F00E1878B /* MyScene.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyScene.m; sourceTree = ""; }; 61 | D17E1979176DC63F00E1878B /* Spaceship.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Spaceship.png; sourceTree = ""; }; 62 | D17E197B176DC63F00E1878B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 63 | D17E1981176DC64000E1878B /* SpriteKitSimpleGameTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SpriteKitSimpleGameTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | D17E1982176DC64000E1878B /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 65 | D17E198A176DC64000E1878B /* SpriteKitSimpleGameTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SpriteKitSimpleGameTests-Info.plist"; sourceTree = ""; }; 66 | D17E198C176DC64000E1878B /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 67 | D17E198E176DC64000E1878B /* SpriteKitSimpleGameTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SpriteKitSimpleGameTests.m; sourceTree = ""; }; 68 | D17E1999176DC68000E1878B /* background-music-aac.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "background-music-aac.caf"; sourceTree = ""; }; 69 | D17E199A176DC68000E1878B /* pew-pew-lei.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "pew-pew-lei.caf"; sourceTree = ""; }; 70 | D17E4CB317760ECB00B56F56 /* ResultScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResultScene.h; sourceTree = ""; }; 71 | D17E4CB417760ECB00B56F56 /* ResultScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ResultScene.m; sourceTree = ""; }; 72 | /* End PBXFileReference section */ 73 | 74 | /* Begin PBXFrameworksBuildPhase section */ 75 | D17E1953176DC63F00E1878B /* Frameworks */ = { 76 | isa = PBXFrameworksBuildPhase; 77 | buildActionMask = 2147483647; 78 | files = ( 79 | D17E195C176DC63F00E1878B /* CoreGraphics.framework in Frameworks */, 80 | D17E195E176DC63F00E1878B /* UIKit.framework in Frameworks */, 81 | D17E1960176DC63F00E1878B /* SpriteKit.framework in Frameworks */, 82 | D17E195A176DC63F00E1878B /* Foundation.framework in Frameworks */, 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | }; 86 | D17E197E176DC64000E1878B /* Frameworks */ = { 87 | isa = PBXFrameworksBuildPhase; 88 | buildActionMask = 2147483647; 89 | files = ( 90 | D17E1983176DC64000E1878B /* XCTest.framework in Frameworks */, 91 | D17E1985176DC64000E1878B /* UIKit.framework in Frameworks */, 92 | D17E1984176DC64000E1878B /* Foundation.framework in Frameworks */, 93 | ); 94 | runOnlyForDeploymentPostprocessing = 0; 95 | }; 96 | /* End PBXFrameworksBuildPhase section */ 97 | 98 | /* Begin PBXGroup section */ 99 | D17E194D176DC63F00E1878B = { 100 | isa = PBXGroup; 101 | children = ( 102 | D17E1961176DC63F00E1878B /* SpriteKitSimpleGame */, 103 | D17E1988176DC64000E1878B /* SpriteKitSimpleGameTests */, 104 | D17E1958176DC63F00E1878B /* Frameworks */, 105 | D17E1957176DC63F00E1878B /* Products */, 106 | ); 107 | sourceTree = ""; 108 | }; 109 | D17E1957176DC63F00E1878B /* Products */ = { 110 | isa = PBXGroup; 111 | children = ( 112 | D17E1956176DC63F00E1878B /* SpriteKitSimpleGame.app */, 113 | D17E1981176DC64000E1878B /* SpriteKitSimpleGameTests.xctest */, 114 | ); 115 | name = Products; 116 | sourceTree = ""; 117 | }; 118 | D17E1958176DC63F00E1878B /* Frameworks */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | D17E1959176DC63F00E1878B /* Foundation.framework */, 122 | D17E195B176DC63F00E1878B /* CoreGraphics.framework */, 123 | D17E195D176DC63F00E1878B /* UIKit.framework */, 124 | D17E195F176DC63F00E1878B /* SpriteKit.framework */, 125 | D17E1982176DC64000E1878B /* XCTest.framework */, 126 | ); 127 | name = Frameworks; 128 | sourceTree = ""; 129 | }; 130 | D17E1961176DC63F00E1878B /* SpriteKitSimpleGame */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | D17E4CB317760ECB00B56F56 /* ResultScene.h */, 134 | D17E4CB417760ECB00B56F56 /* ResultScene.m */, 135 | D17E196A176DC63F00E1878B /* AppDelegate.h */, 136 | D17E196B176DC63F00E1878B /* AppDelegate.m */, 137 | D17E196D176DC63F00E1878B /* Main_iPhone.storyboard */, 138 | D17E1970176DC63F00E1878B /* Main_iPad.storyboard */, 139 | D17E1973176DC63F00E1878B /* ViewController.h */, 140 | D17E1974176DC63F00E1878B /* ViewController.m */, 141 | D17E1976176DC63F00E1878B /* MyScene.h */, 142 | D17E1977176DC63F00E1878B /* MyScene.m */, 143 | D17E1979176DC63F00E1878B /* Spaceship.png */, 144 | D17E197B176DC63F00E1878B /* Images.xcassets */, 145 | D17E1962176DC63F00E1878B /* Supporting Files */, 146 | ); 147 | path = SpriteKitSimpleGame; 148 | sourceTree = ""; 149 | }; 150 | D17E1962176DC63F00E1878B /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | D17E1998176DC68000E1878B /* Sounds */, 154 | D17E1963176DC63F00E1878B /* SpriteKitSimpleGame-Info.plist */, 155 | D17E1964176DC63F00E1878B /* InfoPlist.strings */, 156 | D17E1967176DC63F00E1878B /* main.m */, 157 | D17E1969176DC63F00E1878B /* SpriteKitSimpleGame-Prefix.pch */, 158 | ); 159 | name = "Supporting Files"; 160 | sourceTree = ""; 161 | }; 162 | D17E1988176DC64000E1878B /* SpriteKitSimpleGameTests */ = { 163 | isa = PBXGroup; 164 | children = ( 165 | D17E198E176DC64000E1878B /* SpriteKitSimpleGameTests.m */, 166 | D17E1989176DC64000E1878B /* Supporting Files */, 167 | ); 168 | path = SpriteKitSimpleGameTests; 169 | sourceTree = ""; 170 | }; 171 | D17E1989176DC64000E1878B /* Supporting Files */ = { 172 | isa = PBXGroup; 173 | children = ( 174 | D17E198A176DC64000E1878B /* SpriteKitSimpleGameTests-Info.plist */, 175 | D17E198B176DC64000E1878B /* InfoPlist.strings */, 176 | ); 177 | name = "Supporting Files"; 178 | sourceTree = ""; 179 | }; 180 | D17E1998176DC68000E1878B /* Sounds */ = { 181 | isa = PBXGroup; 182 | children = ( 183 | D17E1999176DC68000E1878B /* background-music-aac.caf */, 184 | D17E199A176DC68000E1878B /* pew-pew-lei.caf */, 185 | ); 186 | path = Sounds; 187 | sourceTree = ""; 188 | }; 189 | /* End PBXGroup section */ 190 | 191 | /* Begin PBXNativeTarget section */ 192 | D17E1955176DC63F00E1878B /* SpriteKitSimpleGame */ = { 193 | isa = PBXNativeTarget; 194 | buildConfigurationList = D17E1992176DC64000E1878B /* Build configuration list for PBXNativeTarget "SpriteKitSimpleGame" */; 195 | buildPhases = ( 196 | D17E1952176DC63F00E1878B /* Sources */, 197 | D17E1953176DC63F00E1878B /* Frameworks */, 198 | D17E1954176DC63F00E1878B /* Resources */, 199 | ); 200 | buildRules = ( 201 | ); 202 | dependencies = ( 203 | ); 204 | name = SpriteKitSimpleGame; 205 | productName = SpriteKitSimpleGame; 206 | productReference = D17E1956176DC63F00E1878B /* SpriteKitSimpleGame.app */; 207 | productType = "com.apple.product-type.application"; 208 | }; 209 | D17E1980176DC64000E1878B /* SpriteKitSimpleGameTests */ = { 210 | isa = PBXNativeTarget; 211 | buildConfigurationList = D17E1995176DC64000E1878B /* Build configuration list for PBXNativeTarget "SpriteKitSimpleGameTests" */; 212 | buildPhases = ( 213 | D17E197D176DC64000E1878B /* Sources */, 214 | D17E197E176DC64000E1878B /* Frameworks */, 215 | D17E197F176DC64000E1878B /* Resources */, 216 | ); 217 | buildRules = ( 218 | ); 219 | dependencies = ( 220 | D17E1987176DC64000E1878B /* PBXTargetDependency */, 221 | ); 222 | name = SpriteKitSimpleGameTests; 223 | productName = SpriteKitSimpleGameTests; 224 | productReference = D17E1981176DC64000E1878B /* SpriteKitSimpleGameTests.xctest */; 225 | productType = "com.apple.product-type.bundle.unit-test"; 226 | }; 227 | /* End PBXNativeTarget section */ 228 | 229 | /* Begin PBXProject section */ 230 | D17E194E176DC63F00E1878B /* Project object */ = { 231 | isa = PBXProject; 232 | attributes = { 233 | LastUpgradeCheck = 0500; 234 | ORGANIZATIONNAME = "王 巍"; 235 | TargetAttributes = { 236 | D17E1980176DC64000E1878B = { 237 | TestTargetID = D17E1955176DC63F00E1878B; 238 | }; 239 | }; 240 | }; 241 | buildConfigurationList = D17E1951176DC63F00E1878B /* Build configuration list for PBXProject "SpriteKitSimpleGame" */; 242 | compatibilityVersion = "Xcode 3.2"; 243 | developmentRegion = English; 244 | hasScannedForEncodings = 0; 245 | knownRegions = ( 246 | en, 247 | Base, 248 | ); 249 | mainGroup = D17E194D176DC63F00E1878B; 250 | productRefGroup = D17E1957176DC63F00E1878B /* Products */; 251 | projectDirPath = ""; 252 | projectRoot = ""; 253 | targets = ( 254 | D17E1955176DC63F00E1878B /* SpriteKitSimpleGame */, 255 | D17E1980176DC64000E1878B /* SpriteKitSimpleGameTests */, 256 | ); 257 | }; 258 | /* End PBXProject section */ 259 | 260 | /* Begin PBXResourcesBuildPhase section */ 261 | D17E1954176DC63F00E1878B /* Resources */ = { 262 | isa = PBXResourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | D17E199C176DC68000E1878B /* pew-pew-lei.caf in Resources */, 266 | D17E197A176DC63F00E1878B /* Spaceship.png in Resources */, 267 | D17E197C176DC63F00E1878B /* Images.xcassets in Resources */, 268 | D17E199B176DC68000E1878B /* background-music-aac.caf in Resources */, 269 | D17E1972176DC63F00E1878B /* Main_iPad.storyboard in Resources */, 270 | D17E196F176DC63F00E1878B /* Main_iPhone.storyboard in Resources */, 271 | D17E1966176DC63F00E1878B /* InfoPlist.strings in Resources */, 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | D17E197F176DC64000E1878B /* Resources */ = { 276 | isa = PBXResourcesBuildPhase; 277 | buildActionMask = 2147483647; 278 | files = ( 279 | D17E198D176DC64000E1878B /* InfoPlist.strings in Resources */, 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | /* End PBXResourcesBuildPhase section */ 284 | 285 | /* Begin PBXSourcesBuildPhase section */ 286 | D17E1952176DC63F00E1878B /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | D17E1978176DC63F00E1878B /* MyScene.m in Sources */, 291 | D17E4CB517760ECB00B56F56 /* ResultScene.m in Sources */, 292 | D17E1975176DC63F00E1878B /* ViewController.m in Sources */, 293 | D17E196C176DC63F00E1878B /* AppDelegate.m in Sources */, 294 | D17E1968176DC63F00E1878B /* main.m in Sources */, 295 | ); 296 | runOnlyForDeploymentPostprocessing = 0; 297 | }; 298 | D17E197D176DC64000E1878B /* Sources */ = { 299 | isa = PBXSourcesBuildPhase; 300 | buildActionMask = 2147483647; 301 | files = ( 302 | D17E198F176DC64000E1878B /* SpriteKitSimpleGameTests.m in Sources */, 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | /* End PBXSourcesBuildPhase section */ 307 | 308 | /* Begin PBXTargetDependency section */ 309 | D17E1987176DC64000E1878B /* PBXTargetDependency */ = { 310 | isa = PBXTargetDependency; 311 | target = D17E1955176DC63F00E1878B /* SpriteKitSimpleGame */; 312 | targetProxy = D17E1986176DC64000E1878B /* PBXContainerItemProxy */; 313 | }; 314 | /* End PBXTargetDependency section */ 315 | 316 | /* Begin PBXVariantGroup section */ 317 | D17E1964176DC63F00E1878B /* InfoPlist.strings */ = { 318 | isa = PBXVariantGroup; 319 | children = ( 320 | D17E1965176DC63F00E1878B /* en */, 321 | ); 322 | name = InfoPlist.strings; 323 | sourceTree = ""; 324 | }; 325 | D17E196D176DC63F00E1878B /* Main_iPhone.storyboard */ = { 326 | isa = PBXVariantGroup; 327 | children = ( 328 | D17E196E176DC63F00E1878B /* Base */, 329 | ); 330 | name = Main_iPhone.storyboard; 331 | sourceTree = ""; 332 | }; 333 | D17E1970176DC63F00E1878B /* Main_iPad.storyboard */ = { 334 | isa = PBXVariantGroup; 335 | children = ( 336 | D17E1971176DC63F00E1878B /* Base */, 337 | ); 338 | name = Main_iPad.storyboard; 339 | sourceTree = ""; 340 | }; 341 | D17E198B176DC64000E1878B /* InfoPlist.strings */ = { 342 | isa = PBXVariantGroup; 343 | children = ( 344 | D17E198C176DC64000E1878B /* en */, 345 | ); 346 | name = InfoPlist.strings; 347 | sourceTree = ""; 348 | }; 349 | /* End PBXVariantGroup section */ 350 | 351 | /* Begin XCBuildConfiguration section */ 352 | D17E1990176DC64000E1878B /* Debug */ = { 353 | isa = XCBuildConfiguration; 354 | buildSettings = { 355 | ALWAYS_SEARCH_USER_PATHS = NO; 356 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 357 | CLANG_CXX_LIBRARY = "libc++"; 358 | CLANG_ENABLE_MODULES = YES; 359 | CLANG_ENABLE_OBJC_ARC = YES; 360 | CLANG_WARN_BOOL_CONVERSION = YES; 361 | CLANG_WARN_CONSTANT_CONVERSION = YES; 362 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 363 | CLANG_WARN_EMPTY_BODY = YES; 364 | CLANG_WARN_ENUM_CONVERSION = YES; 365 | CLANG_WARN_INT_CONVERSION = YES; 366 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 367 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 368 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 369 | COPY_PHASE_STRIP = NO; 370 | GCC_C_LANGUAGE_STANDARD = gnu99; 371 | GCC_DYNAMIC_NO_PIC = NO; 372 | GCC_OPTIMIZATION_LEVEL = 0; 373 | GCC_PREPROCESSOR_DEFINITIONS = ( 374 | "DEBUG=1", 375 | "$(inherited)", 376 | ); 377 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 378 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 379 | GCC_WARN_UNDECLARED_SELECTOR = YES; 380 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 381 | GCC_WARN_UNUSED_FUNCTION = YES; 382 | GCC_WARN_UNUSED_VARIABLE = YES; 383 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 384 | ONLY_ACTIVE_ARCH = YES; 385 | SDKROOT = iphoneos; 386 | TARGETED_DEVICE_FAMILY = "1,2"; 387 | }; 388 | name = Debug; 389 | }; 390 | D17E1991176DC64000E1878B /* Release */ = { 391 | isa = XCBuildConfiguration; 392 | buildSettings = { 393 | ALWAYS_SEARCH_USER_PATHS = NO; 394 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 395 | CLANG_CXX_LIBRARY = "libc++"; 396 | CLANG_ENABLE_MODULES = YES; 397 | CLANG_ENABLE_OBJC_ARC = YES; 398 | CLANG_WARN_BOOL_CONVERSION = YES; 399 | CLANG_WARN_CONSTANT_CONVERSION = YES; 400 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 401 | CLANG_WARN_EMPTY_BODY = YES; 402 | CLANG_WARN_ENUM_CONVERSION = YES; 403 | CLANG_WARN_INT_CONVERSION = YES; 404 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 405 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 406 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 407 | COPY_PHASE_STRIP = YES; 408 | ENABLE_NS_ASSERTIONS = NO; 409 | GCC_C_LANGUAGE_STANDARD = gnu99; 410 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 411 | GCC_WARN_UNDECLARED_SELECTOR = YES; 412 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 413 | GCC_WARN_UNUSED_FUNCTION = YES; 414 | GCC_WARN_UNUSED_VARIABLE = YES; 415 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 416 | SDKROOT = iphoneos; 417 | TARGETED_DEVICE_FAMILY = "1,2"; 418 | VALIDATE_PRODUCT = YES; 419 | }; 420 | name = Release; 421 | }; 422 | D17E1993176DC64000E1878B /* Debug */ = { 423 | isa = XCBuildConfiguration; 424 | buildSettings = { 425 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 426 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 427 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 428 | GCC_PREFIX_HEADER = "SpriteKitSimpleGame/SpriteKitSimpleGame-Prefix.pch"; 429 | INFOPLIST_FILE = "SpriteKitSimpleGame/SpriteKitSimpleGame-Info.plist"; 430 | PRODUCT_NAME = "$(TARGET_NAME)"; 431 | SPRITEKIT_TEXTURE_ATLAS_OUTPUT = YES; 432 | WRAPPER_EXTENSION = app; 433 | }; 434 | name = Debug; 435 | }; 436 | D17E1994176DC64000E1878B /* Release */ = { 437 | isa = XCBuildConfiguration; 438 | buildSettings = { 439 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 440 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 441 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 442 | GCC_PREFIX_HEADER = "SpriteKitSimpleGame/SpriteKitSimpleGame-Prefix.pch"; 443 | INFOPLIST_FILE = "SpriteKitSimpleGame/SpriteKitSimpleGame-Info.plist"; 444 | PRODUCT_NAME = "$(TARGET_NAME)"; 445 | SPRITEKIT_TEXTURE_ATLAS_OUTPUT = YES; 446 | WRAPPER_EXTENSION = app; 447 | }; 448 | name = Release; 449 | }; 450 | D17E1996176DC64000E1878B /* Debug */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SpriteKitSimpleGame.app/SpriteKitSimpleGame"; 454 | FRAMEWORK_SEARCH_PATHS = ( 455 | "$(SDKROOT)/Developer/Library/Frameworks", 456 | "$(inherited)", 457 | "$(SYSTEM_APPS_DIR)/Xcode5-DP.app/Contents/Developer/Library/Frameworks", 458 | ); 459 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 460 | GCC_PREFIX_HEADER = "SpriteKitSimpleGame/SpriteKitSimpleGame-Prefix.pch"; 461 | GCC_PREPROCESSOR_DEFINITIONS = ( 462 | "DEBUG=1", 463 | "$(inherited)", 464 | ); 465 | INFOPLIST_FILE = "SpriteKitSimpleGameTests/SpriteKitSimpleGameTests-Info.plist"; 466 | PRODUCT_NAME = "$(TARGET_NAME)"; 467 | TEST_HOST = "$(BUNDLE_LOADER)"; 468 | WRAPPER_EXTENSION = xctest; 469 | }; 470 | name = Debug; 471 | }; 472 | D17E1997176DC64000E1878B /* Release */ = { 473 | isa = XCBuildConfiguration; 474 | buildSettings = { 475 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/SpriteKitSimpleGame.app/SpriteKitSimpleGame"; 476 | FRAMEWORK_SEARCH_PATHS = ( 477 | "$(SDKROOT)/Developer/Library/Frameworks", 478 | "$(inherited)", 479 | "$(SYSTEM_APPS_DIR)/Xcode5-DP.app/Contents/Developer/Library/Frameworks", 480 | ); 481 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 482 | GCC_PREFIX_HEADER = "SpriteKitSimpleGame/SpriteKitSimpleGame-Prefix.pch"; 483 | INFOPLIST_FILE = "SpriteKitSimpleGameTests/SpriteKitSimpleGameTests-Info.plist"; 484 | PRODUCT_NAME = "$(TARGET_NAME)"; 485 | TEST_HOST = "$(BUNDLE_LOADER)"; 486 | WRAPPER_EXTENSION = xctest; 487 | }; 488 | name = Release; 489 | }; 490 | /* End XCBuildConfiguration section */ 491 | 492 | /* Begin XCConfigurationList section */ 493 | D17E1951176DC63F00E1878B /* Build configuration list for PBXProject "SpriteKitSimpleGame" */ = { 494 | isa = XCConfigurationList; 495 | buildConfigurations = ( 496 | D17E1990176DC64000E1878B /* Debug */, 497 | D17E1991176DC64000E1878B /* Release */, 498 | ); 499 | defaultConfigurationIsVisible = 0; 500 | defaultConfigurationName = Release; 501 | }; 502 | D17E1992176DC64000E1878B /* Build configuration list for PBXNativeTarget "SpriteKitSimpleGame" */ = { 503 | isa = XCConfigurationList; 504 | buildConfigurations = ( 505 | D17E1993176DC64000E1878B /* Debug */, 506 | D17E1994176DC64000E1878B /* Release */, 507 | ); 508 | defaultConfigurationIsVisible = 0; 509 | defaultConfigurationName = Release; 510 | }; 511 | D17E1995176DC64000E1878B /* Build configuration list for PBXNativeTarget "SpriteKitSimpleGameTests" */ = { 512 | isa = XCConfigurationList; 513 | buildConfigurations = ( 514 | D17E1996176DC64000E1878B /* Debug */, 515 | D17E1997176DC64000E1878B /* Release */, 516 | ); 517 | defaultConfigurationIsVisible = 0; 518 | defaultConfigurationName = Release; 519 | }; 520 | /* End XCConfigurationList section */ 521 | }; 522 | rootObject = D17E194E176DC63F00E1878B /* Project object */; 523 | } 524 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame.xcodeproj/project.xcworkspace/xcuserdata/onevcat.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame.xcodeproj/project.xcworkspace/xcuserdata/onevcat.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SpriteKitSimpleGame.xcodeproj/xcuserdata/onevcat.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame.xcodeproj/xcuserdata/onevcat.xcuserdatad/xcschemes/SpriteKitSimpleGame.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 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame.xcodeproj/xcuserdata/onevcat.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SpriteKitSimpleGame.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | D17E1955176DC63F00E1878B 16 | 17 | primary 18 | 19 | 20 | D17E1980176DC64000E1878B 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SpriteKitSimpleGame 4 | // 5 | // Created by 王 巍 on 13-6-16. 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SpriteKitSimpleGame 4 | // 5 | // Created by 王 巍 on 13-6-16. 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @implementation AppDelegate 12 | 13 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 14 | { 15 | // Override point for customization after application launch. 16 | return YES; 17 | } 18 | 19 | - (void)applicationWillResignActive:(UIApplication *)application 20 | { 21 | // 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. 22 | // 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. 23 | } 24 | 25 | - (void)applicationDidEnterBackground:(UIApplication *)application 26 | { 27 | // 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. 28 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 29 | } 30 | 31 | - (void)applicationWillEnterForeground:(UIApplication *)application 32 | { 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 | - (void)applicationDidBecomeActive:(UIApplication *)application 37 | { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application 42 | { 43 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Base.lproj/Main_iPad.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 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Base.lproj/Main_iPhone.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 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/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" : "60x60", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "ipad", 15 | "size" : "29x29", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "50x50", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "50x50", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "72x72", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "72x72", 41 | "scale" : "2x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /SpriteKitSimpleGame/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 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Images.xcassets/monster.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "monster.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "monster@2x.png" 12 | } 13 | ], 14 | "info" : { 15 | "version" : 1, 16 | "author" : "xcode" 17 | } 18 | } -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Images.xcassets/monster.imageset/monster.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame/Images.xcassets/monster.imageset/monster.png -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Images.xcassets/monster.imageset/monster@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame/Images.xcassets/monster.imageset/monster@2x.png -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Images.xcassets/player.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "player.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "player@2x.png" 12 | } 13 | ], 14 | "info" : { 15 | "version" : 1, 16 | "author" : "xcode" 17 | } 18 | } -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Images.xcassets/player.imageset/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame/Images.xcassets/player.imageset/player.png -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Images.xcassets/player.imageset/player@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame/Images.xcassets/player.imageset/player@2x.png -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Images.xcassets/projectile.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x", 6 | "filename" : "projectile.png" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x", 11 | "filename" : "projectile@2x.png" 12 | } 13 | ], 14 | "info" : { 15 | "version" : 1, 16 | "author" : "xcode" 17 | } 18 | } -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Images.xcassets/projectile.imageset/projectile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame/Images.xcassets/projectile.imageset/projectile.png -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Images.xcassets/projectile.imageset/projectile@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame/Images.xcassets/projectile.imageset/projectile@2x.png -------------------------------------------------------------------------------- /SpriteKitSimpleGame/MyScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // MyScene.h 3 | // SpriteKitSimpleGame 4 | // 5 | 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface MyScene : SKScene 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/MyScene.m: -------------------------------------------------------------------------------- 1 | // 2 | // MyScene.m 3 | // SpriteKitSimpleGame 4 | // 5 | // Created by 王 巍 on 13-6-16. 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import "MyScene.h" 10 | #import 11 | #import 12 | #import "ResultScene.h" 13 | 14 | @interface MyScene() 15 | @property (nonatomic, strong) NSMutableArray *monsters; 16 | @property (nonatomic, strong) NSMutableArray *projectiles; 17 | 18 | @property (nonatomic, strong) AVAudioPlayer *bgmPlayer; 19 | @property (nonatomic, strong) SKAction *projectileSoundEffectAction; 20 | 21 | @property (nonatomic, assign) int monstersDestroyed; 22 | @end 23 | 24 | @implementation MyScene 25 | 26 | -(id)initWithSize:(CGSize)size { 27 | if (self = [super initWithSize:size]) { 28 | /* Setup your scene here */ 29 | NSString *bgmPath = [[NSBundle mainBundle] pathForResource:@"background-music-aac" ofType:@"caf"]; 30 | self.bgmPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:bgmPath] error:NULL]; 31 | self.bgmPlayer.numberOfLoops = -1; 32 | [self.bgmPlayer play]; 33 | 34 | self.projectileSoundEffectAction = [SKAction playSoundFileNamed:@"pew-pew-lei.caf" waitForCompletion:NO]; 35 | 36 | self.monsters = [NSMutableArray array]; 37 | self.projectiles = [NSMutableArray array]; 38 | 39 | //1 Set background color for this scene 40 | self.backgroundColor = [SKColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; 41 | 42 | //2 Create a new sprite 43 | SKSpriteNode *player = [SKSpriteNode spriteNodeWithImageNamed:@"player"]; 44 | 45 | //3 Set it's position to the center right edge of screen 46 | player.position = CGPointMake(player.size.width/2, size.height/2); 47 | 48 | //4 Add it to current scene 49 | [self addChild:player]; 50 | 51 | //5 Repeat add monster to the scene every 1 second. 52 | SKAction *actionAddMonster = [SKAction runBlock:^{ 53 | [self addMonster]; 54 | }]; 55 | SKAction *actionWaitNextMonster = [SKAction waitForDuration:1]; 56 | [self runAction:[SKAction repeatActionForever:[SKAction sequence:@[actionAddMonster,actionWaitNextMonster]]]]; 57 | } 58 | 59 | return self; 60 | } 61 | 62 | - (void) addMonster { 63 | SKSpriteNode *monster = [SKSpriteNode spriteNodeWithImageNamed:@"monster"]; 64 | 65 | //1 Determine where to spawn the monster along the Y axis 66 | CGSize winSize = self.size; 67 | int minY = monster.size.height / 2; 68 | int maxY = winSize.height - monster.size.height/2; 69 | int rangeY = maxY - minY; 70 | int actualY = (arc4random() % rangeY) + minY; 71 | 72 | //2 Create the monster slightly off-screen along the right edge, 73 | // and along a random position along the Y axis as calculated above 74 | monster.position = CGPointMake(winSize.width + monster.size.width/2, actualY); 75 | [self addChild:monster]; 76 | 77 | //3 Determine speed of the monster 78 | int minDuration = 2.0; 79 | int maxDuration = 4.0; 80 | int rangeDuration = maxDuration - minDuration; 81 | int actualDuration = (arc4random() % rangeDuration) + minDuration; 82 | 83 | //4 Create the actions. Move monster sprite across the screen and remove it from scene after finished. 84 | SKAction *actionMove = [SKAction moveTo:CGPointMake(-monster.size.width/2, actualY) 85 | duration:actualDuration]; 86 | SKAction *actionMoveDone = [SKAction runBlock:^{ 87 | [monster removeFromParent]; 88 | [self.monsters removeObject:monster]; 89 | [self changeToResultSceneWithWon:NO]; 90 | //TODO: Show a lose scene 91 | }]; 92 | [monster runAction:[SKAction sequence:@[actionMove,actionMoveDone]]]; 93 | 94 | [self.monsters addObject:monster]; 95 | } 96 | 97 | -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 98 | /* Called when a touch begins */ 99 | 100 | for (UITouch *touch in touches) { 101 | //1 Set up initial location of projectile 102 | CGSize winSize = self.size; 103 | SKSpriteNode *projectile = [SKSpriteNode spriteNodeWithImageNamed:@"projectile.png"]; 104 | projectile.position = CGPointMake(projectile.size.width/2, winSize.height/2); 105 | 106 | //2 Get the touch location tn the scene and calculate offset 107 | CGPoint location = [touch locationInNode:self]; 108 | CGPoint offset = CGPointMake(location.x - projectile.position.x, location.y - projectile.position.y); 109 | 110 | // Bail out if you are shooting down or backwards 111 | if (offset.x <= 0) return; 112 | // Ok to add now - we've double checked position 113 | [self addChild:projectile]; 114 | 115 | int realX = winSize.width + (projectile.size.width/2); 116 | float ratio = (float) offset.y / (float) offset.x; 117 | int realY = (realX * ratio) + projectile.position.y; 118 | CGPoint realDest = CGPointMake(realX, realY); 119 | 120 | //3 Determine the length of how far you're shooting 121 | int offRealX = realX - projectile.position.x; 122 | int offRealY = realY - projectile.position.y; 123 | float length = sqrtf((offRealX*offRealX)+(offRealY*offRealY)); 124 | float velocity = self.size.width/1; // projectile speed. 125 | float realMoveDuration = length/velocity; 126 | 127 | //4 Move projectile to actual endpoint and play the throw sound effect 128 | SKAction *moveAction = [SKAction moveTo:realDest duration:realMoveDuration]; 129 | SKAction *projectileCastAction = [SKAction group:@[moveAction,self.projectileSoundEffectAction]]; 130 | [projectile runAction:projectileCastAction completion:^{ 131 | [projectile removeFromParent]; 132 | [self.projectiles removeObject:projectile]; 133 | }]; 134 | 135 | [self.projectiles addObject:projectile]; 136 | } 137 | } 138 | 139 | -(void)update:(CFTimeInterval)currentTime { 140 | /* Called before each frame is rendered */ 141 | NSMutableArray *projectilesToDelete = [[NSMutableArray alloc] init]; 142 | for (SKSpriteNode *projectile in self.projectiles) { 143 | 144 | NSMutableArray *monstersToDelete = [[NSMutableArray alloc] init]; 145 | for (SKSpriteNode *monster in self.monsters) { 146 | 147 | if (CGRectIntersectsRect(projectile.frame, monster.frame)) { 148 | [monstersToDelete addObject:monster]; 149 | } 150 | } 151 | 152 | for (SKSpriteNode *monster in monstersToDelete) { 153 | [self.monsters removeObject:monster]; 154 | [monster removeFromParent]; 155 | 156 | self.monstersDestroyed++; 157 | if (self.monstersDestroyed >= 30) { 158 | [self changeToResultSceneWithWon:YES]; 159 | } 160 | } 161 | 162 | if (monstersToDelete.count > 0) { 163 | [projectilesToDelete addObject:projectile]; 164 | } 165 | } 166 | 167 | for (SKSpriteNode *projectile in projectilesToDelete) { 168 | [self.projectiles removeObject:projectile]; 169 | [projectile removeFromParent]; 170 | } 171 | } 172 | 173 | -(void) changeToResultSceneWithWon:(BOOL)won 174 | { 175 | [self.bgmPlayer stop]; 176 | self.bgmPlayer = nil; 177 | ResultScene *rs = [[ResultScene alloc] initWithSize:self.size won:won]; 178 | SKTransition *reveal = [SKTransition revealWithDirection:SKTransitionDirectionUp duration:1.0]; 179 | [self.scene.view presentScene:rs transition:reveal]; 180 | } 181 | 182 | @end 183 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/ResultScene.h: -------------------------------------------------------------------------------- 1 | // 2 | // ResultScene.h 3 | // SpriteKitSimpleGame 4 | // 5 | // Created by 王 巍 on 13-6-22. 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ResultScene : SKScene 12 | -(instancetype)initWithSize:(CGSize)size won:(BOOL)won; 13 | @end 14 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/ResultScene.m: -------------------------------------------------------------------------------- 1 | // 2 | // ResultScene.m 3 | // SpriteKitSimpleGame 4 | // 5 | // Created by 王 巍 on 13-6-22. 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import "ResultScene.h" 10 | #import "MyScene.h" 11 | 12 | @implementation ResultScene 13 | 14 | -(instancetype)initWithSize:(CGSize)size won:(BOOL)won 15 | { 16 | if (self = [super initWithSize:size]) { 17 | self.backgroundColor = [SKColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]; 18 | 19 | //1 Add a result label to the middle of screen 20 | SKLabelNode *resultLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"]; 21 | resultLabel.text = won ? @"You win!" : @"You lose"; 22 | resultLabel.fontSize = 30; 23 | resultLabel.fontColor = [SKColor blackColor]; 24 | resultLabel.position = CGPointMake(CGRectGetMidX(self.frame), 25 | CGRectGetMidY(self.frame)); 26 | [self addChild:resultLabel]; 27 | 28 | //2 Add a retry label below the result label 29 | SKLabelNode *retryLabel = [SKLabelNode labelNodeWithFontNamed:@"Chalkduster"]; 30 | retryLabel.text = @"Try again"; 31 | retryLabel.fontSize = 20; 32 | retryLabel.fontColor = [SKColor blueColor]; 33 | retryLabel.position = CGPointMake(resultLabel.position.x, resultLabel.position.y * 0.8); 34 | //3 Give a name for this node, it will help up to find the node later. 35 | retryLabel.name = @"retryLabel"; 36 | [self addChild:retryLabel]; 37 | } 38 | return self; 39 | } 40 | 41 | -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 42 | { 43 | for (UITouch *touch in touches) { 44 | CGPoint touchLocation = [touch locationInNode:self]; 45 | SKNode *node = [self nodeAtPoint:touchLocation]; 46 | 47 | if ([node.name isEqualToString:@"retryLabel"]) { 48 | [self changeToGameScene]; 49 | } 50 | } 51 | } 52 | 53 | -(void) changeToGameScene 54 | { 55 | MyScene *ms = [MyScene sceneWithSize:self.size]; 56 | SKTransition *reveal = [SKTransition revealWithDirection:SKTransitionDirectionDown duration:1.0]; 57 | [self.scene.view presentScene:ms transition:reveal]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Sounds/background-music-aac.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame/Sounds/background-music-aac.caf -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Sounds/pew-pew-lei.caf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame/Sounds/pew-pew-lei.caf -------------------------------------------------------------------------------- /SpriteKitSimpleGame/Spaceship.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/onevcat/SpriteKitSimpleGame/97c5b51692d3a4c0f64cf1469b56b21b9359b819/SpriteKitSimpleGame/Spaceship.png -------------------------------------------------------------------------------- /SpriteKitSimpleGame/SpriteKitSimpleGame-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.onevcat.${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 | UIMainStoryboardFile 28 | Main_iPhone 29 | UIMainStoryboardFile~ipad 30 | Main_iPad 31 | UIRequiredDeviceCapabilities 32 | 33 | armv7 34 | 35 | UIStatusBarHidden 36 | 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UISupportedInterfaceOrientations~ipad 43 | 44 | UIInterfaceOrientationLandscapeLeft 45 | UIInterfaceOrientationLandscapeRight 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/SpriteKitSimpleGame-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_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SpriteKitSimpleGame 4 | // 5 | 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface ViewController : UIViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SpriteKitSimpleGame 4 | // 5 | // Created by 王 巍 on 13-6-16. 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "MyScene.h" 11 | #import "ResultScene.h" 12 | 13 | @implementation ViewController 14 | 15 | - (void)viewDidAppear:(BOOL)animated 16 | { 17 | [super viewDidAppear:animated]; 18 | 19 | // Configure the view. 20 | SKView * skView = (SKView *)self.view; 21 | skView.showsFPS = YES; 22 | skView.showsNodeCount = YES; 23 | 24 | // Create and configure the scene. 25 | SKScene * scene = [MyScene sceneWithSize:skView.bounds.size]; 26 | scene.scaleMode = SKSceneScaleModeAspectFill; 27 | 28 | // Present the scene. 29 | [skView presentScene:scene]; 30 | } 31 | 32 | #pragma mark - Rotation 33 | - (BOOL)shouldAutorotate { 34 | return YES; 35 | } 36 | 37 | - (NSUInteger)supportedInterfaceOrientations { 38 | return UIInterfaceOrientationMaskLandscape; 39 | } 40 | 41 | - (void)didReceiveMemoryWarning 42 | { 43 | [super didReceiveMemoryWarning]; 44 | // Release any cached data, images, etc that aren't in use. 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /SpriteKitSimpleGame/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SpriteKitSimpleGame 4 | // 5 | // Created by 王 巍 on 13-6-16. 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SpriteKitSimpleGameTests/SpriteKitSimpleGameTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.onevcat.${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 | UIInterfaceOrientation 22 | UIInterfaceOrientationLandscapeRight 23 | 24 | 25 | -------------------------------------------------------------------------------- /SpriteKitSimpleGameTests/SpriteKitSimpleGameTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SpriteKitSimpleGameTests.m 3 | // SpriteKitSimpleGameTests 4 | // 5 | // Created by 王 巍 on 13-6-16. 6 | // Copyright (c) 2013年 王 巍. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SpriteKitSimpleGameTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SpriteKitSimpleGameTests 16 | 17 | - (void)setUp 18 | { 19 | [super setUp]; 20 | 21 | // Set-up code here. 22 | } 23 | 24 | - (void)tearDown 25 | { 26 | // Tear-down code here. 27 | 28 | [super tearDown]; 29 | } 30 | 31 | - (void)testExample 32 | { 33 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /SpriteKitSimpleGameTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | --------------------------------------------------------------------------------