我正在尝试将SKScene覆盖在SCNScene上。当我在模拟器和iPhone6+上运行我的应用程序时,overlayScene(SKScene)按预期显示,但当我尝试在iPhone5 (尝试了2个不同的设备)上运行它时,overlayScene没有出现。
有人知道为什么吗?这两个设备都运行在iOS 9.2.1上。我只在这两款机型上测试过这款应用。下面是我在GameViewController.Swift中的代码
//Configure the view
sceneView = self.view as? SCNView
//Configure the scene
sceneView.scene = gameScene
sceneView.playing = true
sceneView.backgroundColor = UIColor.blackColor()
sceneView.antialiasingMode = SCNAntialiasingMode.Multisampling4X
let overlayScene = OverlayScene(size: self.view.bounds.size)
sceneView.overlaySKScene = overlayScene谢谢!
发布于 2016-08-06 22:11:37
我从上面@StephenT提到的开发者论坛得到了这个解决方案,但我认为一些代码可能会有所帮助。
在Xcode提供的库存/模板代码中,Storyboard将顶层视图指定为SKView,并且应该通过SCNView对象将初始SCNScene添加到顶层视图。这意味着当我将SKView添加到SCNScene时,我遇到了这样的问题,即SKView不会显示在任何使用OpenGL的设备上(与金属相反)。
因此,对我有效的解决方案是:
Main.storyboard -> ViewController -> view
应设置为SCNView,而不是SKView。
然后,在ViewController中:
- (void) viewDidLoad {
[super viewDidLoad];
// Configure the root view.
//
SCNView *scnView = (SCNView*)self.view;
WorldSceneView *world = [[WorldSceneView alloc] initWithFrame:self.view.frame];
// Create and configure the scene.
//
HUDScene *hudScene = [HUDScene hudSceneWithSize:scnView.bounds.size andHUDDelegate:world];
// Associate the HUD SKScene with the SCNView.
//
world.overlaySKScene = hudScene;
[scnView addSubview:world];
}这对我来说是一种享受,无论是在Metal和OpenGL设备上,还是模拟器上。
https://stackoverflow.com/questions/35936540
复制相似问题