diff --git a/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/Contents.json b/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/Contents.json new file mode 100644 index 0000000..231694f --- /dev/null +++ b/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "SkyBackground.jpg", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/SkyBackground.jpg b/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/SkyBackground.jpg new file mode 100644 index 0000000..8b499d5 Binary files /dev/null and b/GoldWars/GoldWars/Assets.xcassets/SkyBackground.imageset/SkyBackground.jpg differ diff --git a/GoldWars/GoldWars/GameViewController.swift b/GoldWars/GoldWars/GameViewController.swift index 2f7d3d6..29f521d 100644 --- a/GoldWars/GoldWars/GameViewController.swift +++ b/GoldWars/GoldWars/GameViewController.swift @@ -17,7 +17,8 @@ class GameViewController: UIViewController { if let view = self.view as! SKView? { if let scene = SKScene(fileNamed: "MenuScene") { - //scene.scaleMode = .aspectFill + scene.size = self.view.bounds.size + scene.scaleMode = .aspectFill view.presentScene(scene) //TODO: create dev profile or remove on delivery view.showsFPS = true diff --git a/GoldWars/GoldWars/Scenes/GameScene.swift b/GoldWars/GoldWars/Scenes/GameScene.swift index b941b7d..8a2f2d4 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,13 @@ class GameScene: SKScene{ } } + override func update(_ currentTime: TimeInterval) { + self.enumerateChildNodes(withName: "clouds", using: ({ + (node, error) in + node.position.x -= 2 + if node.position.x < -(self.scene?.size.width)! { + node.position.x += (self.scene?.size.width)! * 3 + } + })) + } } diff --git a/GoldWars/GoldWars/Scenes/MenuScene.sks b/GoldWars/GoldWars/Scenes/MenuScene.sks index 4eb9991..487cd23 100644 Binary files a/GoldWars/GoldWars/Scenes/MenuScene.sks and b/GoldWars/GoldWars/Scenes/MenuScene.sks differ diff --git a/GoldWars/GoldWars/Scenes/MenuScene.swift b/GoldWars/GoldWars/Scenes/MenuScene.swift index 733d788..46b4af3 100644 --- a/GoldWars/GoldWars/Scenes/MenuScene.swift +++ b/GoldWars/GoldWars/Scenes/MenuScene.swift @@ -13,7 +13,20 @@ class MenuScene: SKScene { var startGameButtonNode:SKSpriteNode! var settingsButtonNode:SKSpriteNode! - + override func sceneDidLoad() { + for i in 0...2 { + let sky = SKSpriteNode(imageNamed: "SkyBackground") + sky.name = "clouds" + sky.zPosition = -1 + sky.size = CGSize(width: self.size.width, height: self.size.height) + sky.position = CGPoint(x: CGFloat(i) * sky.size.width , y: (self.frame.size.height / 2)) + + self.addChild(sky) + } + } + + + override func touchesBegan(_ touches: Set, with event: UIEvent?) { guard let touch = touches.first else { return @@ -33,4 +46,14 @@ class MenuScene: SKScene { } } + override func update(_ currentTime: TimeInterval) { + self.enumerateChildNodes(withName: "clouds", using: ({ + (node, error) in + node.position.x -= 2 + if node.position.x < -(self.scene?.size.width)! { + node.position.x += (self.scene?.size.width)! * 3 + } + })) + } + }