如果你還沒有找到答案,我確實找到了一種方法來做到這一點。我正在做一些非常相似的事情。
在我的情況下,我有一個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