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 view = self.view as! SKView? {
|
||||||
if let scene = SKScene(fileNamed: "MenuScene") {
|
if let scene = SKScene(fileNamed: "MenuScene") {
|
||||||
//scene.scaleMode = .aspectFill
|
scene.size = self.view.bounds.size
|
||||||
|
scene.scaleMode = .aspectFill
|
||||||
view.presentScene(scene)
|
view.presentScene(scene)
|
||||||
//TODO: create dev profile or remove on delivery
|
//TODO: create dev profile or remove on delivery
|
||||||
view.showsFPS = true
|
view.showsFPS = true
|
||||||
|
@ -132,10 +132,7 @@ class GameScene: SKScene{
|
|||||||
override func update(_ currentTime: TimeInterval) {
|
override func update(_ currentTime: TimeInterval) {
|
||||||
self.enumerateChildNodes(withName: "clouds", using: ({
|
self.enumerateChildNodes(withName: "clouds", using: ({
|
||||||
(node, error) in
|
(node, error) in
|
||||||
// 1
|
|
||||||
node.position.x -= 2
|
node.position.x -= 2
|
||||||
print("node position x = \(node.position.x)")
|
|
||||||
// 2
|
|
||||||
if node.position.x < -(self.scene?.size.width)! {
|
if node.position.x < -(self.scene?.size.width)! {
|
||||||
node.position.x += (self.scene?.size.width)! * 3
|
node.position.x += (self.scene?.size.width)! * 3
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -13,7 +13,20 @@ class MenuScene: SKScene {
|
|||||||
var startGameButtonNode:SKSpriteNode!
|
var startGameButtonNode:SKSpriteNode!
|
||||||
var settingsButtonNode: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?) {
|
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
|
||||||
guard let touch = touches.first else {
|
guard let touch = touches.first else {
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user