Spritekit Game Scene stop when first time contact after add Game Center to the game

203 views Asked by At

I use sprite kit, and before I use GameCenter, everything goes fine, but after I add GameCenter, some problems come. After the game scene shows first time, when two sprite contact first time (note that here I will add score), the game scene will stop for around two seconds, and the fps is around zero, but before it is around 60, this is so strange, right? After this contact, everything goes smoothly then, this only happen when first time after launch the game, and I did some changes. Firstly, I comment out the code about adding score when the two sprite contact, and strange, the scene will not stop now, earthing goes fine, but I have to add the score, because the user already win a score. So then I did some advance contact before the game start, which means that the original score is -1, and I did the advance contact, so when the game starts, the score is started from 0, but unexpectedly, the scene will still stop when the user is playing when first time two nodes contact, so I really do not know what the problem is now.

Note that, why would I said that the problem is the Game Center, because when I do not connect the internet , everything goes smoothly, which means I will not add the score to the Game center. But strange again, so I guess that the problem must be adding score to the GameCenter, so I comment out all the method that will add score to the game center, so I guess now everything is fine now, but , the problem is still happen, so now nothing I can do, So why this problem, did any one of you met this problem before?

My code:

let' if collision == physicsCategory.basket4 | physicsCategory.bugnode { if contact.bodyA.categoryBitMask == physicsCategory.basket4 { contact.bodyB.node?.removeFromParent() } else{ contact.bodyA.node?.removeFromParent() } scoreama++ println("get teh shittttttttttttttttttttttttt") scoreLabel.text = "(scoreama)" finalScore1.text = "(scoreama)" showScore() } '

1

There are 1 answers

0
Aryaman Goel On BEST ANSWER

If you call the Game Center function from GameScene then bring the game center code to GameScene and change 'view' to 'self.view!'. It should then work!