From 5b7c5039e14ad29ba130367c7a9b3e63528db9f7 Mon Sep 17 00:00:00 2001 From: Niko Jochim Date: Sat, 2 May 2020 00:14:21 +0200 Subject: [PATCH] add background to menu-scene --- GoldWars/GoldWars/GameViewController.swift | 3 ++- GoldWars/GoldWars/Scenes/GameScene.swift | 3 --- GoldWars/GoldWars/Scenes/MenuScene.sks | Bin 8253 -> 8154 bytes GoldWars/GoldWars/Scenes/MenuScene.swift | 25 ++++++++++++++++++++- 4 files changed, 26 insertions(+), 5 deletions(-) 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 4f8477c..8a2f2d4 100644 --- a/GoldWars/GoldWars/Scenes/GameScene.swift +++ b/GoldWars/GoldWars/Scenes/GameScene.swift @@ -132,10 +132,7 @@ 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 } diff --git a/GoldWars/GoldWars/Scenes/MenuScene.sks b/GoldWars/GoldWars/Scenes/MenuScene.sks index 4eb9991a14933fbd3987919cff165479fea8779a..487cd23a7a2dcd5f44cbf4f673bb5d5095227c64 100644 GIT binary patch delta 4359 zcmcIm2~-qE8m_9D9;WS?p6Z#NK12j0Y81g4hHH|Iq7oCMfI2E3C~}NQKtN8F;1uzW z7&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;s^NWe6!bFZ+^zyU=ElY&Ci+_m=~EBo0poGnOB%snpc_En1kjf zbF+E3`LMa&e8zmve9`=8^ZVux%=gUq%|DrciQ=LnqfAk;QSng;QT?O5Q3Ij|MU4~m zf9{1e@Rx1`30PA;M5$xbUbjLKr2C5i*5w!UQ2(m?0Di#lmW# zSvVjZ6b=jR!YjfV;hb<;_=~t&Tq~{<*NYp)&Ei&ZyVxW)i@U`=;$CsTcu+hn9ubd; z$HkN4DX~p_MLa8>7he-!7vB)y5-$bBx5anFt73=vuK1DoiTIgCwDhthS&}V}SO!@J zThc7)ma&#R%L&WtmP?j^;7FT>vz`gtv^~HNMRBqg-fgyAqi5f6elG~snT$1q%=jEDFuopzx0GuDP58} zr0dcR>85mB`bfGfeJS0OzLLI{ew6OZI@u^&fy2l;2ks3=N|5~uW4?8+czl;T&alxn3$ znWromq&%;@plnb!DO;4?N{jNMa$Gr~oK#LJuPPUnca*;>A1j|KpDSM|Un$=x-ztAs XzK`ajdqxk49v(e1*w!N+MNjx2b(QS2 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 + } + })) + } + }