我想要在呈现需要几秒钟加载的场景之前取消隐藏图像。如果我删除presentScene,loadbsman图像会正确显示。当presentScene存在时,不确定为什么loadscreenman没有出现。在场景加载时出现该图像将是纯粹的奢侈。
if (node.name == “btnGameOnMan") {
loadscreenman.hidden = false
callgammescenefun()
}
func callgammescenefun()
{
loadscreenman.hidden = false
let reveal = SKTransition.doorsCloseHorizontalWithDuration(0.2)
let gameScene = GameScene(size: self.size)
self.view!.presentScene(gameScene, transition: reveal)
}
答案 0 :(得分:0)
如果NSNotification
这样,您可以点node.name == “btnGameOnMan"
:
if (node.name == “btnGameOnMan") {
dispatch_async(dispatch_get_main_queue(), {
loadscreenman.hidden = false
NSNotificationCenter.defaultCenter().postNotificationName("NotificationFired", object: nil)
})
}
然后在您的callgammescenefun()
中收到已解雇的通知:
func callgammescenefun(notification: NSNotification){
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.callgammescenefun(_:)), name: "NotificationFired", object: nil)
.
. //your code
.
}
在此之后,将其写在函数外部:
deinit{
NSNotificationCenter.defaultCenter().removeObserver(self)
}