add background to menu-scene
This commit is contained in:
parent
8d1aa1de66
commit
5b7c5039e1
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
Binary file not shown.
@ -13,6 +13,19 @@ 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<UITouch>, with event: UIEvent?) {
|
||||
guard let touch = touches.first else {
|
||||
@ -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
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user