Combining scripts and spritekit in one screen

Sorry 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 one view, for example. using SpriteKit to render the map in part of the screen when using SceneKit to render the main 3D view?

+1
source share
2 answers

Yes, you can, and it was shown in various demos at WWDC. Take a look at the property overlaySKScene SCNSceneRenderer.

+5
source

One way to use it SpriteKitinternally SceneKitis 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;
0
source

Source: https://habr.com/ru/post/1609299/


All Articles