0
在Xcode項目中使用SpriteKit,我可以使用更新功能在幀之間更新我需要的所有內容。如何在Swift Playground中使用更新功能
例如
override func update(currentTime: CFTimeInterval) {
/* Called before each frame is rendered */
}
我該如何在Xcode Playground中做同樣的事情?
我不認爲這是一個重複NSTimer.scheduledTimerWithTimeInterval in Swift Playground
/// UPDATE ///
我發現,我可以添加一個類,因此覆蓋類來獲得,如更新功能所以。
任何其他代碼如
//: Playground - noun: a place where people can play
import SpriteKit
import XCPlayground
class PrototypeScene: SKScene {
override func update(currentTime: CFTimeInterval) {
print("update" );
callFunctionOutsideClass();
}
}
func callFunctionOutsideClass(){
}
下一個問題是範圍之前添加該代碼。我如何從更新函數中調用Playground主體中的函數?
如果我嘗試任何屬性添加到類我得到一個錯誤 - 「錯誤:類‘PrototypeScene’沒有初始化」
感謝