How do I create a HUD on top of my Scenekit.scene

前端 未结 4 1083
日久生厌
日久生厌 2021-02-08 03:05

I\'m experimenting with Swift and Scenekit. Building a Mac OS X app. It seems quite easy to get a 3d-scene working. But what is scene without some kind of 2D hi-score, radar dis

相关标签:
4条回答
  • 2021-02-08 03:11

    As @Toyos answered, it is simple to day using scnView.overlaySKScene. If you want an example you can check how Apple did it in their Bananas demo.

    0 讨论(0)
  • 2021-02-08 03:14

    try

    scnView.overlaySKScene = aSKScene;
    

    (see SCNSceneRenderer.h) This is the recommended way. An alternative way is to make the SCNView layer backed and add child views or layers (but this is less efficient).

    0 讨论(0)
  • 2021-02-08 03:16

    To create a HUD, do something like the following:

    // SKContainerOverlay is a class which inherits from SKScene
    
        SKContainerOverlay *skContainerOverlay = [[SKContainerOverlay alloc] initWithSize:self.sceneView.bounds.size];
        self.sceneView.overlaySKScene = skContainerOverlay;
        self.sceneView.overlaySKScene.hidden = NO;
        self.sceneView.overlaySKScene.scaleMode = SKSceneScaleModeResizeFill; // Make sure SKScene bounds are the same as our SCNScene
        self.sceneView.overlaySKScene.userInteractionEnabled = YES;
    

    You can create all your SKLabelNode objects inside the custom SKContainerOverlay class.

    0 讨论(0)
  • 2021-02-08 03:20

    As @Toyos said above, you can use

    scnView.overlaySKScene = aSKScene
    

    to superimpose the SKScene on your SCNView.

    However, when I tried this in Swift, I found that the overlaySKScene property only becomes visible if you include an import SpriteKit statement.

    0 讨论(0)
提交回复
热议问题