diff --git a/d-fence/AboutScene.swift b/d-fence/AboutScene.swift index 23bf1c9..4669617 100644 --- a/d-fence/AboutScene.swift +++ b/d-fence/AboutScene.swift @@ -13,70 +13,14 @@ class AboutScene: SKScene { backgroundColor = SKColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 1.0) // Generate labels for every author and the app name - - let title = SKOutlinedLabelNode(fontNamed: "8-Bit-Madness", fontSize: size.height / 5); - title.borderColor = UIColor.black - title.borderWidth = title.fontSize / 4.5 - title.outlinedText = NSLocalizedString("ABOUT", comment: "") - title.name = "title" - title.fontColor = UIColor.white - title.zPosition = 150 - title.position = CGPoint(x: size.width / 2, y: size.height * 0.8) - - let back = SKOutlinedLabelNode(fontNamed: "8-Bit-Madness", fontSize: size.height / 10); - back.borderColor = UIColor.black - back.borderWidth = back.fontSize / 4.5 - back.outlinedText = NSLocalizedString("BACK", comment: "") - back.name = "back" - back.fontColor = UIColor.white - back.zPosition = 150 - back.position = CGPoint(x: back.frame.size.width / 2 * 1.2, y: back.frame.size.height / 2) - - let gameInfo = SKOutlinedLabelNode(fontNamed: "8-Bit-Madness", fontSize: size.height / 10); - gameInfo.borderColor = UIColor.black - gameInfo.borderWidth = gameInfo.fontSize / 4.5 - gameInfo.outlinedText = "d-fence © 2018" - gameInfo.name = "gameInfo" - gameInfo.fontColor = UIColor.white - gameInfo.zPosition = 150 - gameInfo.position = CGPoint(x: size.width / 2, y: size.height / 2) - - let authorInfo1 = SKOutlinedLabelNode(fontNamed: "8-Bit-Madness", fontSize: size.height / 10); - authorInfo1.borderColor = UIColor.black - authorInfo1.borderWidth = authorInfo1.fontSize / 4.5 - authorInfo1.outlinedText = "Jan-Robin Aumann" - authorInfo1.name = "authorInfo" - authorInfo1.fontColor = UIColor.white - authorInfo1.zPosition = 150 - authorInfo1.position = CGPoint(x: size.width / 2, y: size.height / 3) - - let authorInfo2 = SKOutlinedLabelNode(fontNamed: "8-Bit-Madness", fontSize: size.height / 10); - authorInfo2.borderColor = UIColor.black - authorInfo2.borderWidth = authorInfo2.fontSize / 4.5 - authorInfo2.outlinedText = "Oliver Kardos" - authorInfo2.name = "authorInfo" - authorInfo2.fontColor = UIColor.white - authorInfo2.zPosition = 150 - authorInfo2.position = CGPoint(x: size.width / 2, y: size.height / 3 - authorInfo2.frame.height * 1.5) - - let authorInfo3 = SKOutlinedLabelNode(fontNamed: "8-Bit-Madness", fontSize: size.height / 10); - authorInfo3.borderColor = UIColor.black - authorInfo3.borderWidth = authorInfo3.fontSize / 4.5 - authorInfo3.outlinedText = "Hendrik Ulbrich" - authorInfo3.name = "authorInfo" - authorInfo3.fontColor = UIColor.white - authorInfo3.zPosition = 150 - authorInfo3.position = CGPoint(x: size.width / 2, y: size.height / 3 - authorInfo2.frame.height * 3) - - let authorInfo4 = SKOutlinedLabelNode(fontNamed: "8-Bit-Madness", fontSize: size.height / 17); - authorInfo4.borderColor = UIColor.black - authorInfo4.borderWidth = authorInfo4.fontSize / 4.5 - authorInfo4.outlinedText = "Music by Malte Bartels" - authorInfo4.name = "authorInfo" - authorInfo4.fontColor = UIColor.white - authorInfo4.zPosition = 150 - authorInfo4.position = CGPoint(x: size.width / 2, y: size.height / 3 - authorInfo2.frame.height * 4.5) - + let title = generateMenuItem(localizedText: "ABOUT", name: "title", fontSize: size.height / 5, vpos: 0.85, hpos: 0.5) + let back = generateMenuItem(localizedText: "BACK", name: "back", fontSize: size.height / 10, vpos: 0.05, hpos: 0.1) + let gameInfo = generateMenuItem(localizedText: "GAME_CREDIT", name: "gameInfo", fontSize: size.height / 10, vpos: 0.6, hpos: 0.5) + let authorInfo1 = generateMenuItem(localizedText: "AUTHOR1_CREDIT", name: "authorInfo", fontSize:size.height / 10, vpos: 0.45, hpos: 0.5); + let authorInfo2 = generateMenuItem(localizedText: "AUTHOR2_CREDIT", name: "authorInfo", fontSize:size.height / 10, vpos: 0.35, hpos: 0.5); + let authorInfo3 = generateMenuItem(localizedText: "AUTHOR3_CREDIT", name: "authorInfo", fontSize:size.height / 10, vpos: 0.25, hpos: 0.5); + let authorInfo4 = generateMenuItem(localizedText: "MUSIC_CREDIT", name: "authorInfo", fontSize:size.height / 15, vpos: 0.15, hpos: 0.5); + addChild(authorInfo1) addChild(authorInfo2) addChild(authorInfo3) @@ -98,4 +42,19 @@ class AboutScene: SKScene { } } } + + // Generic function for rendering about labels + func generateMenuItem(localizedText: String, name: String, fontSize: CGFloat, vpos: CGFloat, hpos: CGFloat) -> SKLabelNode { + let label = SKOutlinedLabelNode(fontNamed: "8-Bit-Madness", fontSize: fontSize); + label.borderColor = UIColor.black + label.borderWidth = label.fontSize / 4.5 + label.outlinedText = NSLocalizedString(localizedText, comment: "") + label.name = name + label.fontColor = UIColor.white + label.zPosition = 150 + label.position = CGPoint(x: size.width * hpos, y: (size.height - label.frame.height / 2) * vpos) + + return label + } + } diff --git a/d-fence/GameScene.swift b/d-fence/GameScene.swift index 7b78922..2373d8a 100644 --- a/d-fence/GameScene.swift +++ b/d-fence/GameScene.swift @@ -561,11 +561,11 @@ class GameScene: SKScene { var k = 1 if num_entries < 9 { k = 1 - } else { + } else { k = num_entries - abs(num_entries - 10) } for i in 0...num_entries - k { - if defaults.value(forKey: "score\(i)") != nil && found == false { + if defaults.value(forKey: "score\(i)") != nil && !found { let k = defaults.value(forKey: "score\(i)") as? Int if k! < self.score { scores_change[i] = score @@ -573,23 +573,20 @@ class GameScene: SKScene { scores_change[i + 1] = defaults.value(forKey: "score\(i)")! as! Int waves_change[i + 1] = defaults.value(forKey: "wave\(i)")! as! Int found = true - } - else { + } else { scores_change[i] = defaults.value(forKey: "score\(i)")! as! Int waves_change[i] = defaults.value(forKey: "wave\(i)")! as! Int } - } - else if defaults.value(forKey: "score\(i)") != nil && found == true { + } else if defaults.value(forKey: "score\(i)") != nil && found { scores_change[i + 1] = defaults.value(forKey: "score\(i)")! as! Int waves_change[i + 1] = defaults.value(forKey: "wave\(i)")! as! Int } } - for i in 0...scores_change.count - 1 { + for i in 0...scores_change.count-1 { defaults.set(scores_change[i], forKey: "score\(i)") defaults.set(waves_change[i], forKey: "wave\(i)") } - } - else { + } else { defaults.set(score, forKey: "score0") defaults.set(waveCount, forKey: "wave0") } diff --git a/d-fence/SKOutlinedLabelNode.swift b/d-fence/SKOutlinedLabelNode.swift index de25b0a..94e3385 100644 --- a/d-fence/SKOutlinedLabelNode.swift +++ b/d-fence/SKOutlinedLabelNode.swift @@ -26,9 +26,13 @@ class SKOutlinedLabelNode: SKLabelNode { } var borderStyle = borderStyleType.under - // Redraw the label each time the outlined text changes. + // Redraw the label each time the outlined text (really) changes. var outlinedText: String! { - didSet { drawText() } + didSet { + if outlinedText != oldValue { + drawText() + } + } } var border: SKShapeNode? diff --git a/d-fence/de.lproj/Localizable.strings b/d-fence/de.lproj/Localizable.strings index 9350c37..a5ffe4c 100644 --- a/d-fence/de.lproj/Localizable.strings +++ b/d-fence/de.lproj/Localizable.strings @@ -22,3 +22,9 @@ "STATS" = "STATISTIK"; "SLINGSHOT" = "SCHLEUDER"; "NEXT WAVE" = "NAECHSTE WELLE"; +"AUTHOR1_CREDIT" = "Jan-Robin Aumann"; +"AUTHOR2_CREDIT" = "Oliver Kardos"; +"AUTHOR3_CREDIT" = "Hendrik Ulbrich"; +"GAME_CREDIT" = "d-fence © 2018"; +"MUSIC_CREDIT" = "Musik von Malte Bartels"; + diff --git a/d-fence/en.lproj/Localizable.strings b/d-fence/en.lproj/Localizable.strings index a97b32f..9c0b1e6 100644 --- a/d-fence/en.lproj/Localizable.strings +++ b/d-fence/en.lproj/Localizable.strings @@ -22,3 +22,8 @@ "STATS" = "STATS"; "SLINGSHOT" = "SLINGSHOT"; "NEXT WAVE" = "NEXT WAVE"; +"AUTHOR1_CREDIT" = "Jan-Robin Aumann"; +"AUTHOR2_CREDIT" = "Oliver Kardos"; +"AUTHOR3_CREDIT" = "Hendrik Ulbrich"; +"GAME_CREDIT" = "d-fence © 2018"; +"MUSIC_CREDIT" = "Music by Malte Bartels";