i have googled the problem and tried the following:
yet im still getting black bars on the xcode simulator on iphone 6.
My gamecontroller looks like this:
import UIKit
import SpriteKit
class GameViewController: UIViewController {
var scene : GameScene!
override func prefersStatusBarHidden() -> Bool {
return true
}
override func viewDidLoad() {
super.viewDidLoad()
let skView = view as! SKView
skView.showsFPS = true
scene = GameScene(size: skView.bounds.size)
scene.scaleMode = .AspectFill
skView.presentScene(scene)
}
}
My Gamescene
import SpriteKit
class GameScene: SKScene {
required init?(coder aDecoder:NSCoder){
super.init(coder: aDecoder)
}
override init(size: CGSize){
super.init(size: size)
var tempText = SKLabelNode(fontNamed: "Copperplate")
tempText.position = CGPoint(x: self.size.width / 2, y: self.size.height / 2)
tempText.text = "Click anywhere to play"
tempText.fontSize = 20
addChild(tempText)
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
var newScene = LevelOne(size: size)
var transition = SKTransition.crossFadeWithDuration(2)
view?.presentScene(newScene, transition: transition);
}
}
and my firstlevel
import Foundation
import SpriteKit
class LevelOne : SKScene{
let background = SKSpriteNode(imageNamed: "bgsmaller")
let player = SKSpriteNode()
required init?(coder aDecoder:NSCoder) {
super.init(coder: aDecoder)
}
override init(size: CGSize) {
super.init(size: size)
// add background
background.anchorPoint = CGPoint(x: 0.5, y: 0.0)
background.position = CGPoint(x: size.width / 2, y: 0.0)
addChild(background)
}
}
any advice would be appreciated. I am new to swift and spriteKit so I don't know where I am going wrong.
Xcode 7 is out now, so I'd update to that. It might fix that bug with the simulator, but it also lets developers test their apps on their physical iDevices for free (no $99 per year licence required), so then you could see if the glitch exists in your code or in the Xcode IDE, that is if you have an iPhone, iPad, or iPod Touch.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.