Bezz
Bezz

Reputation: 118

SpriteNode behind UIImages

I've created a SpriteNode in a scene and it's there, but it is stuck behind all the UIImages and UIButtons I've dragged onto the storyboard.

I tried changing the .zPosition of the spriteNode to 99999999999999, but it doesn't matter.

What do I need to do to get the spriteNode to appear in front of most of the images? Or can I only have one background image?

Upvotes: 1

Views: 121

Answers (1)

CloakedEddy
CloakedEddy

Reputation: 1995

Unfortunately for you, this is impossible. You are combining two rendering hierarchies (UIKit and Sprite Kit) whose children (UIView and SKNode, respectively) do not mingle.

SKNodes are rendered inside the SKScene that contains them. The final rendered image is used as the image for the layer of the owning SKView. From there, UIKit (and CoreAnimation) composite the UIViews.

A hierarchy for illustration purposes:

  • UIView
    • UIButton
    • UIButton
    • SKView (renders an SKScene object)
      • SKNode
      • SKLabelNode
      • SKLabelNode
    • UIImageview

Upvotes: 0

Related Questions