Reputation: 41
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?
Upvotes: 3
Views: 1718
Reputation: 2398
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;
Upvotes: 0
Reputation: 13462
Yes you can and it was shown in various demos at WWDC.
Take a look at the overlaySKScene
property of SCNSceneRenderer
.
Upvotes: 7