I've found a strange behaviour on the Xcode 6 iOS Simulator.
Even with just a menu showing in my GameScene, the Simulator FPS area really low at around 20 FPS.
Are there any known issues, which could cause this issue? Also when I start my game itself, it drops from around 30FPS to 19 FPS immediately.
Here my code which is loaded at startup:
override func didMoveToView(view: SKView) {
var sud:NSUserDefaults = NSUserDefaults.standardUserDefaults()
if(sud.valueForKey("highscores") != nil){
highScores = sud.valueForKey("highscores") as [Int]
}else{
highScores = [0, 0]
sud.setValue(highScores, forKey: "highscores")
}
createColors()
createStartMenu()
}
func createColors(){
colorArray = [
ColorClass(name: "greenSea", color: greenSea),
ColorClass(name: "emerald", color: emerald),
ColorClass(name: "peterRiver", color:peterRiver),
ColorClass(name: "amethyst", color:amethyst),
ColorClass(name: "wetAsphalt", color:wetAsphalt),
ColorClass(name: "sunFlower", color:sunFlower),
ColorClass(name: "carrot", color:carrot),
ColorClass(name: "pumpkin", color:pumpkin),
ColorClass(name: "alizarin", color:alizarin),
ColorClass(name: "pomeGranate", color:pomeGranate),
ColorClass(name: "clouds", color:clouds),
ColorClass(name: "asbestos", color:asbestos)]
}
func setSceneBackground(){
var background = SKSpriteNode(color: myBackgroundcolor, size: CGSizeMake(self.frame.width, self.frame.height))
background.position = CGPointMake(self.frame.width/2, self.frame.height/2)
self.addChild(background)
}
func createStartMenu(){
self.removeAllChildren()
setSceneBackground()
reset()
var background = SKSpriteNode(color: myBackgroundcolor, size: CGSizeMake(self.frame.width/1.2, self.frame.height/1.5))
background.position = CGPointMake(self.frame.width/2, self.frame.height/2)
var buttonSize:CGSize = CGSizeMake(background.size.width - 20, background.size.height/4 - 15)
background.setScale(0)
var alizarin = UIColor(rgba: "#e74c3c")
playLevelsButton = SKSpriteNode(color: alizarin, size: buttonSize)
playLevelsButton.position.y = buttonSize.height + buttonSize.height/2 + 15
var fontSize = buttonSize.height/2
playLevelLabel = SKLabelNode()
playLevelLabel.fontSize = fontSize
playLevelLabel.text = "Easy"
playLevelLabel.name = "playLevelLabel"
playLevelLabel.fontName = myFont
playLevelLabel.zPosition = 1
playLevelLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.Center
playLevelsButton.addChild(playLevelLabel)
var carrot = UIColor(rgba: "#e67e22")
playMoreDifficultButton = SKSpriteNode(color: carrot, size: buttonSize)
playMoreDifficultButton.position.y = buttonSize.height/2 + 5
playMoreDifficultLabel = SKLabelNode()
playMoreDifficultLabel.text = "Difficult"
playMoreDifficultLabel.fontName = myFont
playMoreDifficultLabel.fontSize = fontSize
playMoreDifficultLabel.name = "playMoreDifficultLabel"
playMoreDifficultLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.Center
playMoreDifficultButton.addChild(playMoreDifficultLabel)
var sunFlower = UIColor(rgba: "#f1c40f")
howToPlayButton = SKSpriteNode(color: sunFlower, size: buttonSize)
howToPlayButton.position.y = -buttonSize.height/2 - 5
howToPlayLabel = SKLabelNode()
howToPlayLabel.text = "How To Play"
howToPlayLabel.fontSize = fontSize
howToPlayLabel.fontName = myFont
howToPlayLabel.name = "howToPlayLabel"
howToPlayLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.Center
howToPlayButton.addChild(howToPlayLabel)
var emerald = UIColor(rgba: "#2ecc71")
highScoreButton = SKSpriteNode(color: emerald, size: buttonSize)
highScoreButton.position.y = -buttonSize.height - buttonSize.height/2 - 15
highScoreLabel = SKLabelNode()
highScoreLabel.text = "Highscore"
highScoreLabel.fontSize = fontSize
highScoreLabel.fontName = myFont
highScoreLabel.name = "highScoreLabel"
highScoreLabel.verticalAlignmentMode = SKLabelVerticalAlignmentMode.Center
highScoreButton.addChild(highScoreLabel)
//Names
playLevelsButton.name = "playLevels"
playMoreDifficultButton.name = "playMoreDifficult"
howToPlayButton.name = "howToPlay"
highScoreButton.name = "highScore"
background.addChild(playLevelsButton)
background.addChild(playMoreDifficultButton)
background.addChild(howToPlayButton)
background.addChild(highScoreButton)
self.addChild(background)
background.runAction(SKAction.scaleTo(1, duration: 0.3))
}
func reset(){
correctColors = []
tileArray = []
tempArray = []
amountCorrect = 0
tapped = 0
gameStarted = false
maxTime = nil
timeStamp = 0
tileFrameSize = nil
searchColor = nil
tileColors = []
}
SpriteKit uses OpenGL ES for GPU-accelerated rendering on a device. In the iOS Simulator, OpenGL ES support is provided by a software renderer. As such, any use of OpenGL ES — whether by itself or via SpriteKit or SceneKit — has very different performance characteristics on the simulator versus on an actual device.
Never rely on the iOS Simulator for performance measures, especially when anything GPU-related is involved.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다