0

When the player dies, a little image is showing up saying: aww you're dead. But the code I am using is slowing down my fps as hell, what am I doing wrong?

the game goes on at 60 fps, when the image shows up the fps goes down to 30..

this is the function:

func Dood(){

            let labelDood = SKSpriteNode(imageNamed: "labelDood")
            labelDood.size.width = frame.size.width/1.2
            labelDood.size.height = frame.size.height/4
            labelDood.position.x = frame.size.width/2
            labelDood.position.y = -frame.height/2
            labelDood.zPosition = 3
            var labelLevens = SKLabelNode(fontNamed: "Arial-Bold")
            labelLevens.text = ("3")
            labelLevens.position.x = frame.size.width / 2.13
            labelLevens.position.y = (-frame.size.height / 1.68)
            labelLevens.fontColor = SKColor.blackColor()
            labelLevens.fontSize = frame.size.height / 17
            labelLevens.zPosition = 4
            addChild(labelDood)
            addChild(labelLevens)

            self.runAction(SKAction.sequence([SKAction.waitForDuration(1.0),
            SKAction.runBlock({
            println("doodddd")
            self.kikker.removeFromParent()
            labelDood.removeFromParent()
            labelLevens.removeFromParent()
            self.kikker.position = CGPointMake(self.frame.size.width/2, -self.frame.size.height/20*19)
            self.kikker.zRotation = 0
            self.addChild(self.kikker)
            })
            ] ))


}
DNC
  • 443
  • 1
  • 6
  • 20
  • Does this happen on the simulator, device, or both? – pwightman Nov 30 '14 at 06:14
  • simulator. I Do not have access to test on device. – DNC Nov 30 '14 at 13:52
  • Hm. Nothing from your code looks like it would cause a dramatic slowdown. However, in my experience, the simulator's SpriteKit performance is terrible compared to devices, just about anything will cause its framerate to drop. So there's a good chance this isn't a problem on real devices. – pwightman Nov 30 '14 at 15:43

0 Answers0