diff --git a/GoldWars/GoldWars.xcodeproj/project.pbxproj b/GoldWars/GoldWars.xcodeproj/project.pbxproj index 8d513d0..41c82b9 100644 --- a/GoldWars/GoldWars.xcodeproj/project.pbxproj +++ b/GoldWars/GoldWars.xcodeproj/project.pbxproj @@ -33,8 +33,6 @@ 9EC86B9F245C88A300796EF3 /* Modal.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86B9E245C88A300796EF3 /* Modal.swift */; }; 9EC86BA6245C8AD000796EF3 /* ModalType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EC86BA5245C8AD000796EF3 /* ModalType.swift */; }; ABA03DA0244BD54F00A66916 /* Base.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABA03D9F244BD54F00A66916 /* Base.swift */; }; - C0BB0378245CCF4D00EEAC81 /* BackgroundNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0BB0377245CCF4D00EEAC81 /* BackgroundNode.swift */; }; - C0BB037A245CCF6300EEAC81 /* BackgroundComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C0BB0379245CCF6300EEAC81 /* BackgroundComponent.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -88,8 +86,6 @@ 9EC86BA5245C8AD000796EF3 /* ModalType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalType.swift; sourceTree = ""; }; 9ECD3699245C91F7008DEEBD /* GoldWars.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = GoldWars.entitlements; sourceTree = ""; }; ABA03D9F244BD54F00A66916 /* Base.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Base.swift; sourceTree = ""; }; - C0BB0377245CCF4D00EEAC81 /* BackgroundNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundNode.swift; sourceTree = ""; }; - C0BB0379245CCF6300EEAC81 /* BackgroundComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundComponent.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -185,8 +181,6 @@ 9E78ACBD245CC9C000526FF7 /* AtkBoostSkillComponent.swift */, 9E78ACC3245CCA3600526FF7 /* SpySkillComponent.swift */, 9E78ACC1245CC9EE00526FF7 /* DefBoostSkillComponent.swift */, - C0BB0377245CCF4D00EEAC81 /* BackgroundNode.swift */, - C0BB0379245CCF6300EEAC81 /* BackgroundComponent.swift */, ); path = Components; sourceTree = ""; @@ -381,9 +375,7 @@ 110360D9244B101A008610AF /* GameScene.swift in Sources */, 116060F7245C57D2004E5A36 /* EntityManager.swift in Sources */, 9E78ACBA245CBDAF00526FF7 /* HUD.swift in Sources */, - C0BB0378245CCF4D00EEAC81 /* BackgroundNode.swift in Sources */, 11738A3B24508F68004426F1 /* Unit.swift in Sources */, - C0BB037A245CCF6300EEAC81 /* BackgroundComponent.swift in Sources */, 11036113244B3E30008610AF /* MenuScene.swift in Sources */, 9EA3ABE9245C6DAA006BC61D /* DefaultBaseComponent.swift in Sources */, 9EA3ABED245C8143006BC61D /* ModalBackgroundComponent.swift in Sources */, diff --git a/GoldWars/GoldWars/Components/BackgroundComponent.swift b/GoldWars/GoldWars/Components/BackgroundComponent.swift deleted file mode 100644 index 8c8d3a8..0000000 --- a/GoldWars/GoldWars/Components/BackgroundComponent.swift +++ /dev/null @@ -1,29 +0,0 @@ -// -// BackgroundComponent.swift -// GoldWars -// -// Created by Tim Herbst on 01.05.20. -// Copyright © 2020 SP2. All rights reserved. -// - -import UIKit -import GameplayKit -import SpriteKit - -class BackgroundComponent: GKComponent { - var sky: BackgroundNode - - init(size: CGSize, anchorPoint: CGPoint) { - super.init() - self.sky = BackgroundNode(imageNamed: "cloud") - self.sky.name = "clouds" - self.sky.size = CGSize(width: size.width, height: size.height) - self.sky.position = CGPoint(x: CGFloat(i) * sky.size.width , y: anchorPoint.y / 2) - - - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } -} diff --git a/GoldWars/GoldWars/Components/BackgroundNode.swift b/GoldWars/GoldWars/Components/BackgroundNode.swift deleted file mode 100644 index 74d61e8..0000000 --- a/GoldWars/GoldWars/Components/BackgroundNode.swift +++ /dev/null @@ -1,28 +0,0 @@ -// -// BackgroundNode.swift -// GoldWars -// -// Created by Tim Herbst on 01.05.20. -// Copyright © 2020 SP2. All rights reserved. -// - -import UIKit -import SpriteKit - -class BackgroundNode: SKSpriteNode { - - func update(_ currentTime: TimeInterval) { - scrollBackground() - } - - func scrollBackground(){ - self.enumerateChildNodes(withName: "clouds", using: ({ - (node, error) in - node.position.x -= 2 - print("node position x = \(node.position.x)") - if node.position.x < -(self.scene?.size.width)! { - node.position.x += (self.scene?.size.width)! * 3 - } - })) - } -} diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index b941b7d..4f8477c 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -18,8 +18,21 @@ class GameScene: SKScene{ entityManager.add(Base(textureName: "Base", team: .team1)) entityManager.add(Base(textureName: "Base", team: .team2)) entityManager.add(HUD(size: self.size)) - initMap() + createBackground() + + } + + func createBackground() { + for i in 0...2 { + let sky = SKSpriteNode(imageNamed: "SkyBackground") + sky.name = "clouds" + sky.zPosition = -1 + sky.size = CGSize(width: (self.scene?.size.width)!, height: (self.scene?.size.height)!) + sky.position = CGPoint(x: CGFloat(i) * sky.size.width , y: (self.frame.size.height / 2)) + + self.addChild(sky) + } } // TODO: Issue #24 create Map generation Service @@ -116,4 +129,16 @@ class GameScene: SKScene{ } } + override func update(_ currentTime: TimeInterval) { + self.enumerateChildNodes(withName: "clouds", using: ({ + (node, error) in + // 1 + node.position.x -= 2 + print("node position x = \(node.position.x)") + // 2 + if node.position.x < -(self.scene?.size.width)! { + node.position.x += (self.scene?.size.width)! * 3 + } + })) + } }