问题
Apologies if this is a newbie question, i'm still trying to find my way around Swift and SpriteKit / SceneKit.
Is it possible to combine SpriteKit and SceneKit in a single view, e.g. using SpriteKit to render a map in portion of the screen while using SceneKit to render the main 3D view?
回答1:
Yes you can and it was shown in various demos at WWDC.
Take a look at the overlaySKScene
property of SCNSceneRenderer
.
回答2:
One way of using SpriteKit
within SceneKit
is as follows:
SCNView *sceneView = [[SCNView alloc] initWithFrame:[[UIScreen mainScreen] bounds] options:@{@"SCNPreferredRenderingAPIKey": @(SCNRenderingAPIOpenGLES3)}];
[self.view addSubview:sceneView];
sceneView.scene = [SCNScene scene];
// ... whatever else you're doing
SKContainerOverlay *skOverlay = [[SKContainerOverlay alloc] initWithSize:self.sceneView.bounds.size];
skOverlay.delegate = self;
self.sceneView.overlaySKScene = skOverlay; // the key to your question
self.sceneView.overlaySKScene.hidden = NO;
self.sceneView.overlaySKScene.scaleMode = SKSceneScaleModeResizeFill;
来源:https://stackoverflow.com/questions/26237302/combining-scenekit-and-spritekit-in-a-single-screen