Combining scenekit and spritekit in a single screen

痞子三分冷 提交于 2019-12-14 04:17:36

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!