如果你还没有找到答案,我确实找到了一种方法来做到这一点。我正在做一些非常相似的事情。
在我的情况下,我有一个UIView从我的场景中作为暂停菜单被调用。我已经让班级和变量名称变得更加模糊,以便他们也可以适用于您的情况。
class MyView: UIView {
var scene: MyScene!
var button: UIButton!
init(frame: CGRect, scene: MyScene){
super.init(frame: frame)
self.scene = scene
//initialize the button
button.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "buttonTapped"))
}
func buttonTapped(){
self.removeFromSuperview() // this removes my menu from the scene
scene.doTheThing() // this calls the method on my scene
}
这里是我的场景的相关部分。
class MyScene: SKScene {
func doTheThing(){
//this is a function on the scene. You can pass any variable you want through the function.
}
}
在你的情况,它听起来像第一个屏幕是UIView和第二个屏幕是SKScene。
您可能想首先制作SKScene,暂停它,然后在场景前添加UIView。一旦角色被选中,你可以移除UIView并将角色添加到场景中。
我希望这可以回答你的问题。如果它不让我知道。
应该沿着从视图控制器设置游戏场景的变量(查看视图控制器的代码中创建游戏场景的位置)。要从游戏场景设置视图控制器中的变量,请将视图控制器的引用传递到游戏场景,然后使用视图控制器设置变量。 – Gliderman
是不是你的SKView呈现由View Controller控制的SKScene?这就像使用子视图... Gliderman有正确的想法 – MaxKargin
@MaxKargin不,我真正想要做的是在UIView中选择一个字符,并显示由SKScene文件控制的实际游戏中的字符。 – Gabe12