我试图在暂停场景之前添加SKSpriteNode。但是目前我的代码中的场景暂停得很快,以至于没有时间用新的SKSpiteNode渲染帧。在场景未暂停后,将出现SKSpriteNode。在场景暂停之前,我怎么能保证SKSpriteNode是渲染的。这是我的代码:
func pauseScene() {
if (self.scene?.view?.paused == true){
self.pauseNode.removeFromParent()
self.scene?.view?.paused = false
} else if (self.scene?.view?.paused == false){
pauseTexture = SKTexture(imageNamed: "pauseImage")
pauseTexture.filteringMode = SKTextureFilteringMode.Nearest
pauseNode = SKSpriteNode(texture: pauseTexture)
pauseNode.zPosition = 100
pauseNode.position = CGPoint(x: CGRectGetMidX(self.frame), y: CGRectGetMidY(self.frame))
pauseNode.size = CGSize(width: screenSize.width, height: screenSize.height)
self.addChild(pauseNode)
self.scene?.view?.paused = true
}
}