Click ----> for pic :) This is my GameScene as of now, its hard coded and linked to a Global File of that holds scene data
override func didMoveToView(view: SKView) {
super.didMoveToView(view)
playButton.hidden = true
let background = SKSpriteNode(imageNamed: "us-flag")
background.position = CGPoint(x: size.width/2, y: size.height/2 )
background.blendMode = .Replace
background.zPosition = -1
background.size = self.size
addChild(background)
gameOverButton = SKSpriteNode(imageNamed: "gameOver")
gameOverButton.position = CGPoint(x: size.width / 2 , y: scene!.frame.height - 200)
gameOverButton.zPosition = 3
gameOverButton.xScale = 1.5
gameOverButton.yScale = 1.5
gameOverButton.hidden = true
addChild(gameOverButton)
gameScore = CustomSKLabel(fontNamed: "Chalkduster")
gameScore.text = "Votes: 0"
gameScore.position = CGPoint(x: Int((self.size.width - gameScore.frame.width )) , y: 22)
gameScore.horizontalAlignmentMode = .Center
gameScore.fontSize = 27
gameScore.zPosition = 3
gameScore.fontColor = SKColor.whiteColor()
addChild(gameScore)
/* for i in 0 ..< 5 { createSlotAt(CGPoint(x: 160 + (i * 170), y: 410)) }
for i in 0 ..< 4 { createSlotAt(CGPoint(x: 240 + (i * 170), y: 320)) }
for i in 0 ..< 5 { createSlotAt(CGPoint(x: 160 + (i * 170), y: 230)) }
for i in 0 ..< 4 { createSlotAt(CGPoint(x: 240 + (i * 170), y: 140)) }
RunAfterDelay(1) { [unowned self] in
self.createEnemy() */
for i in 0 ..< 5 { createSlotAt(CGPoint(x: 680 + (i * 170), y: 535)) }
for i in 0 ..< 4 { createSlotAt(CGPoint(x: 715 + (i * 170), y: 435)) }
for i in 0 ..< 5 { createSlotAt(CGPoint(x: 680 + (i * 170), y: 335)) }
for i in 0 ..< 4 { createSlotAt(CGPoint(x: 715 + (i * 170), y: 245)) }
RunAfterDelay(1) { [unowned self] in
self.createEnemy()
my game scene is hard coded all other scenes are built in the Scene Editor, my attempt was a universal app, yet decided to release for iPhone only it used to work properly, until ported the game over completely to SpriteKit
GameViewController:
if let scene = WelcomeScene (fileNamed:"WelcomeScene") {
let skView = self.view as! SKView
skView.showsFPS = Constant.DEV.DEBUG
skView.showsNodeCount = Constant.DEV.DEBUG
skView.ignoresSiblingOrder = true
scene.scaleMode = .AspectFit
skView.presentScene(scene)
}
}
override func prefersStatusBarHidden() -> Bool {
return false
}
override func shouldAutorotate() -> Bool {
return true
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return [UIInterfaceOrientationMask.LandscapeRight ,UIInterfaceOrientationMask.LandscapeLeft]
}
}
GlobalSceneDataSwift:
if let scene = sceneToLoad {
scene.size = size
scene.scaleMode = scaleMode
let transition = SKTransition.fadeWithDuration(3)
self.view?.presentScene(scene, transition: transition)
}
}
}
Before I moved to SpriteKit everything was embedded into the GameViewController, I used it as regular ViewController, and embedded subviews, to facilitate the GameScene, worked great until about turn four, when cpu dropped to zero and memory spiked. So I went with SpriteKit. All other scenes look fine for iPhone. Except the GameScene. It pulls in the wrong assets and the scene looks like the picture.
Old code from GameScene with UIKit and SpriteKit Mix in case that helps:
let deviceIdiom = UIScreen.mainScreen().traitCollection.userInterfaceIdiom
switch (deviceIdiom) {
case .Pad:
let active = SKSpriteNode(imageNamed: self.name!)
active.name = self.name
active.size = CGSizeMake(100, 100)
active.position = CGPoint(x: Int( active.frame.width + 0), y: Int(active.frame.height + 10))
addChild(active)
case .Phone: break
case .TV:
let active = SKSpriteNode(imageNamed: self.name!)
active.name = self.name
active.size = CGSizeMake(100, 100)
active.position = CGPoint(x: Int( active.frame.width + 12), y: Int(active.frame.height + 12))
addChild(active)
default: break
}
let w12 = Int(self.size.width / 12)
let w6 = Int(self.size.width / 6)
let w5 = Int(self.size.width / 5)
let h3 = Int(self.size.height / 3)
for i in 0 ..< 5 { createSlotAt(CGPoint(x: w12 + (i * w5), y: h3 + 120 )) }
for i in 0 ..< 4 { createSlotAt(CGPoint(x: w6 + (i * w5), y: h3 + 60)) }
for i in 0 ..< 5 { createSlotAt(CGPoint(x: w12 + (i * w5), y: h3 + 10 )) }
for i in 0 ..< 4 { createSlotAt(CGPoint(x: w6 + (i * w5), y: h3 - 50)) }
RunAfterDelay(1) { [unowned self] in
self.createEnemy()
}
}
Im sticking with SpriteKit, solo because honestly its been a lot more stable, with transitioning scenes especially ones with a lot moving parts. Scene Size 1920 * 1080 back ground images match that setup, I chose that size in case I decide to port to Apple TV later. Thanks Again for everyone who takes the time to answer questions on here. Pic included
Legacy UPDATE Checked Assets and noticed the BackGround Size was off, being this part of the game was created two months ago I forgot that I manually adjusted the picture in code**** Has not solved the problem completely yet, my images show, and the background does not look like a Picnic Blanket.