As I've been coding a game in sprite kit, I've noticed that adding even 1 image severely drops framerate from 60 to 30, is there any reason why this is happening? Am I doing the code inefficiently? It's very simple.
This code runs at 30 FPS
import SpriteKit
class OptionMenu: SKScene
{
var Screen: SKSpriteNode!
override func didMoveToView(view: SKView)
{
Screen = SKSpriteNode()
self.addChild(Screen)
addBg()
}
func addBg(){
let MainMenu = SKSpriteNode(imageNamed: "MainMenu")
MainMenu.position = CGPointMake(frame.width / 2, frame.height / 2)
addChild(MainMenu)
}
}
This code runs at 60 FPS
import SpriteKit
class OptionMenu: SKScene
{
var Screen: SKSpriteNode!
override func didMoveToView(view: SKView)
{
Screen = SKSpriteNode()
self.addChild(Screen)
}
}
I don't understand how just one image can affect framerate this severely? BTW the image is like 1000 by 700 ish pixels Thanks, Brennan
Edit: Also I should add the code in the GameViewController()
override func viewDidLoad() {
super.viewDidLoad()
let scene = OptionMenu()
// Configure the view.
let skView = self.view as SKView
skView.showsFPS = true
skView.showsNodeCount = true
/* Sprite Kit applies additional optimizations to improve rendering performance */
skView.ignoresSiblingOrder = true
/* Set the scale mode to scale to fit the window */
scene.scaleMode = .AspectFill
scene.size = skView.bounds.size
skView.presentScene(scene)
}
Edit 2: A similar thread already exists: iOS Simulator games run very slow (low fps)
My question here is slightly different in that I am wondering if I am capping my framerate unintentionally. When I add an image the FPS stays constant at 30.0 FPS, which would signify to me its not lag due to the poor simulator, but that I am capping it somehow.