我如何获得对aUIView的调用.presentScene(aSKScene,过渡:aSKTransition)与aUI



我如何获得一个调用aUIView。presentScene(aSKScene, transition: aSKTransition)与aUIView.addSubview.

, 的过渡,有问题. .SKTransitionUITextField先发生SKTransition-不一致

同样,UITextField被植入ViewControllerview中,等待SKTransition赶上来

func showScene(theSceneName: String) {
if let ourScene = SKScene(fileNamed: theSceneName) {

addTextFieldToVC(toSceneName: theSceneName)
// NB: theSceneName is passed by Reference so we can
//     return here before we call presentScene(...)
addGamePiecesToScene(toScene: theSceneName)
if let theView = self.view as! SKView? {
theView.ignoresSiblingOrder = true
theView.showsFPS = true
theView.showsNodeCount = true

// Finally, present the scene
let theTransition = SKTransition.doorway(withDuration: 2.0)
theView.presentScene(ourScene, transition: theTransition)
}

}   // if let ourScene

}   // showScene

func addTextFieldToVC(toSceneName: String) {
if (toSceneName == "GameScene") {
if let theView = self.view as! SKView? {
aUITextField = UITextField(frame:CGRectMake(x: aXValue, y: aYValue))
theView.addSubview(aUITextField!)
}
}
}

func addGamePiecesToScene(toScene: SKScene) {
myRoom = SKSpriteNode(texture: SKTexture(imageNamed: roomImg))
myRoom!.zPosition = roomZposition
// etc with .size, .position
toScene.addChild(myRoom!)
}

如上所示,我首先添加UITextField,然后添加SKSpriteNode图像。

但是它们不同步使用SKTransition。它们只同步出现在而不同步SKTransition。

fww,我在showScene中尝试过这个序列,但没有变化:

theView.presentScene(theSceneName, transition: theTransition)
DispatchQueue.main.async {
addTextFieldToVC(toSceneName: theSceneName)
}

我也开始尝试完成处理程序:

override func viewDidLoad() {

super.viewDidLoad()

setupScene()

// Completion Handler for showScene()
showModifiedScene {

if thisSceneName == "GameScene" {  // a global var
addTextFieldToVC(toSceneName: thisSceneName!)
}

}

}   // viewDidLoad

// modified for callback option??
func showScene(theSceneName: String) {
if let ourScene = SKScene(fileNamed: theSceneName) {

addGamePiecesToScene(toScene: ourScene)
showModifiedScene()

}   // if let ourScene

}   // showScene

func showModifiedScene(completionBlock: () -> Void) {
if thisSceneName == "GameScene" {  // a global var
if let ourScene = SKScene(fileNamed: thisSceneName!) {
if let theView = self.view as! SKView? {
theView.ignoresSiblingOrder = true
theView.showsFPS = true
theView.showsNodeCount = true

let theTransition = SKTransition.doorway(withDuration: 2.0)
theView.presentScene(ourScene, transition: theTransition)
}
}
completionBlock()
}

}   // showModifiedScene

,,的过渡,有问题. .SKTransitionUITextField先发生然后是SKTransition- not in uni

我是仍然我在纠结这个…但我觉得是时候叫援军了!在等待髑髅地的时候,我还会继续工作。

尝试添加文本视图,然后将对presentScene()的调用包装在对DispatchQueue.main.async()的调用中。

这样,文本字段将在您开始显示视图之前添加到视图中。

相关内容

  • 没有找到相关文章

最新更新