2016-06-16 36 views
0

我試圖在呈現需要幾秒鐘加載的場景之前取消隱藏圖像。如果我刪除了當前場景,則加載畫面圖像將正確顯示。不知道爲什麼在當前場景存在時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

您可以觸發一個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) 
    } 
+0

非常感謝Dershowitz123。那麼做了這個工作 – NoPizzaTonight

+0

隨時!快樂的編碼! :) – Dershowitz123