├── .gitignore ├── LightingDemo ├── LightingDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist ├── LightingDemo │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── GameScene.sks │ ├── GameScene.swift │ ├── GameViewController.swift │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── appicon-1.png │ │ │ ├── appicon-2.png │ │ │ └── appicon.png │ ├── Info.plist │ └── Sprites │ │ ├── background_01.png │ │ ├── character │ │ ├── 01.png │ │ ├── 01_n.png │ │ ├── 02.png │ │ ├── 02_n.png │ │ ├── 03.png │ │ ├── 03_n.png │ │ ├── 04.png │ │ ├── 04_n.png │ │ ├── 05.png │ │ ├── 05_n.png │ │ ├── 06.png │ │ ├── 06_n.png │ │ ├── 07.png │ │ ├── 07_n.png │ │ ├── 08.png │ │ └── 08_n.png │ │ ├── foreground_01.png │ │ ├── foreground_01_n.png │ │ ├── foreground_02.png │ │ ├── foreground_02_n.png │ │ └── lightbulb.png └── spriteilluminator-project.sip ├── README.md └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | *xcuserdata* 2 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | AAE5DD211B0382330028C3AD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE5DD201B0382330028C3AD /* AppDelegate.swift */; }; 11 | AAE5DD231B0382330028C3AD /* GameScene.sks in Resources */ = {isa = PBXBuildFile; fileRef = AAE5DD221B0382330028C3AD /* GameScene.sks */; }; 12 | AAE5DD251B0382330028C3AD /* GameScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE5DD241B0382330028C3AD /* GameScene.swift */; }; 13 | AAE5DD271B0382330028C3AD /* GameViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE5DD261B0382330028C3AD /* GameViewController.swift */; }; 14 | AAE5DD2A1B0382330028C3AD /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AAE5DD281B0382330028C3AD /* Main.storyboard */; }; 15 | AAE5DD2C1B0382330028C3AD /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AAE5DD2B1B0382330028C3AD /* Images.xcassets */; }; 16 | AAE5DD2F1B0382330028C3AD /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = AAE5DD2D1B0382330028C3AD /* LaunchScreen.xib */; }; 17 | AAE787701B0A44D100B553B5 /* Sprites in Resources */ = {isa = PBXBuildFile; fileRef = AAE7876F1B0A44D100B553B5 /* Sprites */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | AAE5DD1B1B0382330028C3AD /* LightingDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LightingDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | AAE5DD1F1B0382330028C3AD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 23 | AAE5DD201B0382330028C3AD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 24 | AAE5DD221B0382330028C3AD /* GameScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = GameScene.sks; sourceTree = ""; }; 25 | AAE5DD241B0382330028C3AD /* GameScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameScene.swift; sourceTree = ""; }; 26 | AAE5DD261B0382330028C3AD /* GameViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = ""; }; 27 | AAE5DD291B0382330028C3AD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 28 | AAE5DD2B1B0382330028C3AD /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 29 | AAE5DD2E1B0382330028C3AD /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 30 | AAE7876F1B0A44D100B553B5 /* Sprites */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Sprites; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | AAE5DD181B0382330028C3AD /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | AAE5DD121B0382330028C3AD = { 45 | isa = PBXGroup; 46 | children = ( 47 | AAE5DD1D1B0382330028C3AD /* LightingDemo */, 48 | AAE5DD1C1B0382330028C3AD /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | AAE5DD1C1B0382330028C3AD /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | AAE5DD1B1B0382330028C3AD /* LightingDemo.app */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | AAE5DD1D1B0382330028C3AD /* LightingDemo */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | AAE7876F1B0A44D100B553B5 /* Sprites */, 64 | AAE5DD201B0382330028C3AD /* AppDelegate.swift */, 65 | AAE5DD221B0382330028C3AD /* GameScene.sks */, 66 | AAE5DD241B0382330028C3AD /* GameScene.swift */, 67 | AAE5DD261B0382330028C3AD /* GameViewController.swift */, 68 | AAE5DD281B0382330028C3AD /* Main.storyboard */, 69 | AAE5DD2B1B0382330028C3AD /* Images.xcassets */, 70 | AAE5DD2D1B0382330028C3AD /* LaunchScreen.xib */, 71 | AAE5DD1F1B0382330028C3AD /* Info.plist */, 72 | ); 73 | path = LightingDemo; 74 | sourceTree = ""; 75 | }; 76 | /* End PBXGroup section */ 77 | 78 | /* Begin PBXNativeTarget section */ 79 | AAE5DD1A1B0382330028C3AD /* LightingDemo */ = { 80 | isa = PBXNativeTarget; 81 | buildConfigurationList = AAE5DD3E1B0382330028C3AD /* Build configuration list for PBXNativeTarget "LightingDemo" */; 82 | buildPhases = ( 83 | AAE5DD171B0382330028C3AD /* Sources */, 84 | AAE5DD181B0382330028C3AD /* Frameworks */, 85 | AAE5DD191B0382330028C3AD /* Resources */, 86 | ); 87 | buildRules = ( 88 | ); 89 | dependencies = ( 90 | ); 91 | name = LightingDemo; 92 | productName = LightingDemo; 93 | productReference = AAE5DD1B1B0382330028C3AD /* LightingDemo.app */; 94 | productType = "com.apple.product-type.application"; 95 | }; 96 | /* End PBXNativeTarget section */ 97 | 98 | /* Begin PBXProject section */ 99 | AAE5DD131B0382330028C3AD /* Project object */ = { 100 | isa = PBXProject; 101 | attributes = { 102 | LastUpgradeCheck = 1120; 103 | ORGANIZATIONNAME = "CodeAndWeb GmbH"; 104 | TargetAttributes = { 105 | AAE5DD1A1B0382330028C3AD = { 106 | CreatedOnToolsVersion = 6.3; 107 | DevelopmentTeam = 9B2Z3TZMD9; 108 | }; 109 | }; 110 | }; 111 | buildConfigurationList = AAE5DD161B0382330028C3AD /* Build configuration list for PBXProject "LightingDemo" */; 112 | compatibilityVersion = "Xcode 3.2"; 113 | developmentRegion = en; 114 | hasScannedForEncodings = 0; 115 | knownRegions = ( 116 | en, 117 | Base, 118 | ); 119 | mainGroup = AAE5DD121B0382330028C3AD; 120 | productRefGroup = AAE5DD1C1B0382330028C3AD /* Products */; 121 | projectDirPath = ""; 122 | projectRoot = ""; 123 | targets = ( 124 | AAE5DD1A1B0382330028C3AD /* LightingDemo */, 125 | ); 126 | }; 127 | /* End PBXProject section */ 128 | 129 | /* Begin PBXResourcesBuildPhase section */ 130 | AAE5DD191B0382330028C3AD /* Resources */ = { 131 | isa = PBXResourcesBuildPhase; 132 | buildActionMask = 2147483647; 133 | files = ( 134 | AAE5DD2F1B0382330028C3AD /* LaunchScreen.xib in Resources */, 135 | AAE5DD2C1B0382330028C3AD /* Images.xcassets in Resources */, 136 | AAE5DD231B0382330028C3AD /* GameScene.sks in Resources */, 137 | AAE5DD2A1B0382330028C3AD /* Main.storyboard in Resources */, 138 | AAE787701B0A44D100B553B5 /* Sprites in Resources */, 139 | ); 140 | runOnlyForDeploymentPostprocessing = 0; 141 | }; 142 | /* End PBXResourcesBuildPhase section */ 143 | 144 | /* Begin PBXSourcesBuildPhase section */ 145 | AAE5DD171B0382330028C3AD /* Sources */ = { 146 | isa = PBXSourcesBuildPhase; 147 | buildActionMask = 2147483647; 148 | files = ( 149 | AAE5DD251B0382330028C3AD /* GameScene.swift in Sources */, 150 | AAE5DD271B0382330028C3AD /* GameViewController.swift in Sources */, 151 | AAE5DD211B0382330028C3AD /* AppDelegate.swift in Sources */, 152 | ); 153 | runOnlyForDeploymentPostprocessing = 0; 154 | }; 155 | /* End PBXSourcesBuildPhase section */ 156 | 157 | /* Begin PBXVariantGroup section */ 158 | AAE5DD281B0382330028C3AD /* Main.storyboard */ = { 159 | isa = PBXVariantGroup; 160 | children = ( 161 | AAE5DD291B0382330028C3AD /* Base */, 162 | ); 163 | name = Main.storyboard; 164 | sourceTree = ""; 165 | }; 166 | AAE5DD2D1B0382330028C3AD /* LaunchScreen.xib */ = { 167 | isa = PBXVariantGroup; 168 | children = ( 169 | AAE5DD2E1B0382330028C3AD /* Base */, 170 | ); 171 | name = LaunchScreen.xib; 172 | sourceTree = ""; 173 | }; 174 | /* End PBXVariantGroup section */ 175 | 176 | /* Begin XCBuildConfiguration section */ 177 | AAE5DD3C1B0382330028C3AD /* Debug */ = { 178 | isa = XCBuildConfiguration; 179 | buildSettings = { 180 | ALWAYS_SEARCH_USER_PATHS = NO; 181 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 182 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 183 | CLANG_CXX_LIBRARY = "libc++"; 184 | CLANG_ENABLE_MODULES = YES; 185 | CLANG_ENABLE_OBJC_ARC = YES; 186 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 187 | CLANG_WARN_BOOL_CONVERSION = YES; 188 | CLANG_WARN_COMMA = YES; 189 | CLANG_WARN_CONSTANT_CONVERSION = YES; 190 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 191 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 192 | CLANG_WARN_EMPTY_BODY = YES; 193 | CLANG_WARN_ENUM_CONVERSION = YES; 194 | CLANG_WARN_INFINITE_RECURSION = YES; 195 | CLANG_WARN_INT_CONVERSION = YES; 196 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 197 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 198 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 199 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 200 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 201 | CLANG_WARN_STRICT_PROTOTYPES = YES; 202 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 203 | CLANG_WARN_UNREACHABLE_CODE = YES; 204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 205 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 206 | COPY_PHASE_STRIP = NO; 207 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 208 | ENABLE_STRICT_OBJC_MSGSEND = YES; 209 | ENABLE_TESTABILITY = YES; 210 | GCC_C_LANGUAGE_STANDARD = gnu99; 211 | GCC_DYNAMIC_NO_PIC = NO; 212 | GCC_NO_COMMON_BLOCKS = YES; 213 | GCC_OPTIMIZATION_LEVEL = 0; 214 | GCC_PREPROCESSOR_DEFINITIONS = ( 215 | "DEBUG=1", 216 | "$(inherited)", 217 | ); 218 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 219 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 220 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 221 | GCC_WARN_UNDECLARED_SELECTOR = YES; 222 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 223 | GCC_WARN_UNUSED_FUNCTION = YES; 224 | GCC_WARN_UNUSED_VARIABLE = YES; 225 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 226 | MTL_ENABLE_DEBUG_INFO = YES; 227 | ONLY_ACTIVE_ARCH = YES; 228 | SDKROOT = iphoneos; 229 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 230 | SWIFT_VERSION = 5.0; 231 | }; 232 | name = Debug; 233 | }; 234 | AAE5DD3D1B0382330028C3AD /* Release */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_COMMA = YES; 246 | CLANG_WARN_CONSTANT_CONVERSION = YES; 247 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | COPY_PHASE_STRIP = NO; 264 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 265 | ENABLE_NS_ASSERTIONS = NO; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | GCC_C_LANGUAGE_STANDARD = gnu99; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 276 | MTL_ENABLE_DEBUG_INFO = NO; 277 | SDKROOT = iphoneos; 278 | SWIFT_COMPILATION_MODE = wholemodule; 279 | SWIFT_VERSION = 5.0; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Release; 283 | }; 284 | AAE5DD3F1B0382330028C3AD /* Debug */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 288 | CODE_SIGN_IDENTITY = "iPhone Developer"; 289 | DEVELOPMENT_TEAM = 9B2Z3TZMD9; 290 | INFOPLIST_FILE = LightingDemo/Info.plist; 291 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 292 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 293 | PRODUCT_BUNDLE_IDENTIFIER = "caw.$(PRODUCT_NAME:rfc1034identifier)"; 294 | PRODUCT_NAME = "$(TARGET_NAME)"; 295 | SWIFT_VERSION = 5.0; 296 | }; 297 | name = Debug; 298 | }; 299 | AAE5DD401B0382330028C3AD /* Release */ = { 300 | isa = XCBuildConfiguration; 301 | buildSettings = { 302 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 303 | CODE_SIGN_IDENTITY = "iPhone Developer"; 304 | DEVELOPMENT_TEAM = 9B2Z3TZMD9; 305 | INFOPLIST_FILE = LightingDemo/Info.plist; 306 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 307 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 308 | PRODUCT_BUNDLE_IDENTIFIER = "caw.$(PRODUCT_NAME:rfc1034identifier)"; 309 | PRODUCT_NAME = "$(TARGET_NAME)"; 310 | SWIFT_VERSION = 5.0; 311 | }; 312 | name = Release; 313 | }; 314 | /* End XCBuildConfiguration section */ 315 | 316 | /* Begin XCConfigurationList section */ 317 | AAE5DD161B0382330028C3AD /* Build configuration list for PBXProject "LightingDemo" */ = { 318 | isa = XCConfigurationList; 319 | buildConfigurations = ( 320 | AAE5DD3C1B0382330028C3AD /* Debug */, 321 | AAE5DD3D1B0382330028C3AD /* Release */, 322 | ); 323 | defaultConfigurationIsVisible = 0; 324 | defaultConfigurationName = Release; 325 | }; 326 | AAE5DD3E1B0382330028C3AD /* Build configuration list for PBXNativeTarget "LightingDemo" */ = { 327 | isa = XCConfigurationList; 328 | buildConfigurations = ( 329 | AAE5DD3F1B0382330028C3AD /* Debug */, 330 | AAE5DD401B0382330028C3AD /* Release */, 331 | ); 332 | defaultConfigurationIsVisible = 0; 333 | defaultConfigurationName = Release; 334 | }; 335 | /* End XCConfigurationList section */ 336 | }; 337 | rootObject = AAE5DD131B0382330028C3AD /* Project object */; 338 | } 339 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // LightingDemo 4 | // 5 | // Created by Joachim Grill on 13.05.15. 6 | // Copyright (c) 2019 CodeAndWeb GmbH. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | var window: UIWindow? 14 | 15 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { 16 | return true 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 22 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/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 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/GameScene.sks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/GameScene.sks -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/GameScene.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameScene.swift 3 | // LightingDemo 4 | // 5 | // Created by Joachim Grill on 13.05.15. 6 | // Copyright (c) 2019 CodeAndWeb GmbH. All rights reserved. 7 | // 8 | 9 | import SpriteKit 10 | 11 | class GameScene: SKScene { 12 | var _scale: CGFloat = 1.0 13 | var _screenH: CGFloat = 640.0 14 | var _screenW: CGFloat = 960.0 15 | var _lightSprite: SKSpriteNode? 16 | var _backgroundSprite1: SKSpriteNode? 17 | var _backgroundSprite2: SKSpriteNode? 18 | var _foregroundSprite1: SKSpriteNode? 19 | var _foregroundSprite2: SKSpriteNode? 20 | var _ambientColor: UIColor? 21 | 22 | override func didMove(to view: SKView) { 23 | _screenH = view.frame.height 24 | _screenW = view.frame.width 25 | _scale = _screenW / 1920 26 | 27 | _ambientColor = UIColor.darkGray 28 | 29 | initBackground() 30 | initSprite() 31 | initLight() 32 | } 33 | 34 | override func touchesBegan(_ touches: Set, with event: UIEvent?) { 35 | for touch: AnyObject in touches { 36 | _lightSprite?.position = touch.location(in: self) 37 | } 38 | } 39 | 40 | override func touchesMoved(_ touches: Set, with event: UIEvent?) { 41 | for touch: AnyObject in touches { 42 | _lightSprite?.position = touch.location(in: self) 43 | } 44 | } 45 | 46 | override func update(_ currentTime: TimeInterval) { 47 | let y: CGFloat = _screenH / 2.0; 48 | 49 | let backgroundOffset: CGFloat = -CGFloat(Int(currentTime*100) % (1920*2)); 50 | _backgroundSprite1?.position = CGPoint(x:_scale*((backgroundOffset < -1920) ? (3840+backgroundOffset) : backgroundOffset), y:y) 51 | _backgroundSprite2?.position = CGPoint(x:_scale*(1920+backgroundOffset), y:y) 52 | 53 | let foregroundOffset: CGFloat = -CGFloat(Int(currentTime*250) % (1920*2)); 54 | _foregroundSprite1?.position = CGPoint(x:_scale*((foregroundOffset < -1920) ? (3840+foregroundOffset) : foregroundOffset), y:y) 55 | _foregroundSprite2?.position = CGPoint(x:_scale*(1920+foregroundOffset), y:y) 56 | } 57 | 58 | fileprivate func initSprite() { 59 | var animFrames = [SKTexture]() 60 | var normals = [SKTexture]() 61 | for index in 1...8 { 62 | animFrames.append(SKTexture(imageNamed: String(format:"Sprites/character/%02d.png", index))) 63 | normals.append(SKTexture(imageNamed: String(format:"Sprites/character/%02d_n.png", index))) 64 | } 65 | 66 | let sprite = SKSpriteNode(texture: animFrames[0], normalMap: normals[0]) 67 | 68 | let fps = 8.0 69 | 70 | let anim = SKAction.customAction(withDuration: 1.0) { (node, time) in 71 | let index = Int((fps * Double(time))) % animFrames.count 72 | (node as! SKSpriteNode).normalTexture = normals[index] 73 | (node as! SKSpriteNode).texture = animFrames[index] 74 | } 75 | sprite.run(SKAction.repeatForever(anim)) 76 | 77 | sprite.position = CGPoint(x: _screenW / 2, y: _screenH / 2 - 75.0 * _scale) 78 | sprite.setScale(_scale) 79 | sprite.lightingBitMask = 1 80 | //sprite.shadowCastBitMask = 1 81 | 82 | addChild(sprite) 83 | } 84 | 85 | fileprivate func initLight() { 86 | _lightSprite = SKSpriteNode(imageNamed: "Sprites/lightbulb.png") 87 | _lightSprite?.setScale(_scale * 2) 88 | _lightSprite?.position = CGPoint(x: _screenW - 100, y: _screenH - 100) 89 | addChild(_lightSprite!) 90 | 91 | let light = SKLightNode() 92 | light.position = .zero 93 | light.falloff = 1 94 | light.ambientColor = _ambientColor! 95 | light.lightColor = .white 96 | //light.shadowColor = .black 97 | 98 | _lightSprite?.addChild(light) 99 | } 100 | 101 | fileprivate func initBackground() { 102 | backgroundColor = SKColor.black 103 | _backgroundSprite1 = addBackgroundTile(spriteFile: "Sprites/background_01.png"); 104 | _backgroundSprite2 = addBackgroundTile(spriteFile: "Sprites/background_01.png"); 105 | _foregroundSprite1 = addForegroundTile(spriteFile: "Sprites/foreground_01.png", normalsFile:"Sprites/foreground_01_n.png"); 106 | _foregroundSprite2 = addForegroundTile(spriteFile: "Sprites/foreground_02.png", normalsFile:"Sprites/foreground_02_n.png"); 107 | } 108 | 109 | fileprivate func addForegroundTile(spriteFile: String, normalsFile: String) -> SKSpriteNode { 110 | var foreground:SKSpriteNode 111 | 112 | foreground = SKSpriteNode(texture: SKTexture(imageNamed:spriteFile), normalMap: SKTexture(imageNamed:normalsFile)); 113 | foreground.lightingBitMask = 1 114 | 115 | foreground.anchorPoint = CGPoint(x:0, y:0.5) 116 | foreground.setScale(_scale) 117 | addChild(foreground); 118 | 119 | return foreground; 120 | } 121 | 122 | fileprivate func addBackgroundTile(spriteFile: String) -> SKSpriteNode { 123 | var background:SKSpriteNode 124 | 125 | background = SKSpriteNode(imageNamed:spriteFile); 126 | background.color = _ambientColor! 127 | background.colorBlendFactor = 0.75 128 | 129 | background.anchorPoint = CGPoint(x:0, y:0.5) 130 | background.setScale(_scale) 131 | addChild(background); 132 | 133 | return background; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/GameViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GameViewController.swift 3 | // LightingDemo 4 | // 5 | // Created by Joachim Grill on 13.05.15. 6 | // Copyright (c) 2019 CodeAndWeb GmbH. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import SpriteKit 11 | 12 | class GameViewController: UIViewController { 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | self.setup() 16 | } 17 | 18 | override var shouldAutorotate: Bool { 19 | return true 20 | } 21 | 22 | override var supportedInterfaceOrientations: UIInterfaceOrientationMask { 23 | if UIDevice.current.userInterfaceIdiom == .phone { 24 | return .allButUpsideDown 25 | } else { 26 | return .all 27 | } 28 | } 29 | 30 | override var prefersStatusBarHidden: Bool { 31 | return true 32 | } 33 | 34 | fileprivate func setup() { 35 | guard let skView = self.view as? SKView else { return } 36 | let scene = GameScene(size: self.view.bounds.size) 37 | scene.scaleMode = .aspectFill //.aspectFit 38 | scene.isPaused = false 39 | scene.speed = 1.0 40 | skView.presentScene(scene, transition: SKTransition.fade(withDuration: 1)) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "appicon.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "idiom" : "iphone", 11 | "size" : "29x29", 12 | "scale" : "3x" 13 | }, 14 | { 15 | "size" : "40x40", 16 | "idiom" : "iphone", 17 | "filename" : "appicon-1.png", 18 | "scale" : "2x" 19 | }, 20 | { 21 | "idiom" : "iphone", 22 | "size" : "40x40", 23 | "scale" : "3x" 24 | }, 25 | { 26 | "size" : "60x60", 27 | "idiom" : "iphone", 28 | "filename" : "appicon-2.png", 29 | "scale" : "2x" 30 | }, 31 | { 32 | "idiom" : "iphone", 33 | "size" : "60x60", 34 | "scale" : "3x" 35 | } 36 | ], 37 | "info" : { 38 | "version" : 1, 39 | "author" : "xcode" 40 | } 41 | } -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Images.xcassets/AppIcon.appiconset/appicon-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Images.xcassets/AppIcon.appiconset/appicon-1.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Images.xcassets/AppIcon.appiconset/appicon-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Images.xcassets/AppIcon.appiconset/appicon-2.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Images.xcassets/AppIcon.appiconset/appicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Images.xcassets/AppIcon.appiconset/appicon.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 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 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UIStatusBarHidden 34 | 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationLandscapeRight 38 | UIInterfaceOrientationLandscapeLeft 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/background_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/background_01.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/01.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/01_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/01_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/02.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/02_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/02_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/03.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/03_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/03_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/04.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/04_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/04_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/05.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/05_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/05_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/06.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/06_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/06_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/07.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/07_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/07_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/08.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/character/08_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/character/08_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/foreground_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/foreground_01.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/foreground_01_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/foreground_01_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/foreground_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/foreground_02.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/foreground_02_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/foreground_02_n.png -------------------------------------------------------------------------------- /LightingDemo/LightingDemo/Sprites/lightbulb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/LightingDemo/Sprites/lightbulb.png -------------------------------------------------------------------------------- /LightingDemo/spriteilluminator-project.sip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/LightingDemo/spriteilluminator-project.sip -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SpriteKit dynamic lighting demo 2 | --- 3 | 4 | This simple SpriteKit project demonstrates how to use normal maps created with [SpriteIlluminator](https://www.codeandweb.com/spriteilluminator) to lighten your sprites. 5 | 6 | A short tutorial can be found here: [2d dynamic lighting with SpriteKit](https://www.codeandweb.com/blog/2015/05/19/spritekit-dynamic-light-tutorial) 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeAndWeb/spritekit-dynamic-lighting/55f3f1efa92d80e9a7ba618c5bddd0900f410fb9/screenshot.png --------------------------------------------------------------------------------