2
votes

In my storyboard, I have a base UIView, then a UIView containing a square board drawing in a CGRect and buttons and status fields above and below. I tried drawing the playing pieces but animating them became a nightmare so I have rendered them as sprite nodes in an array and they animate themselves. So far so good. Then layer on top of that is a SKView view and I want to present the SpriteKit scene in there with skView.allowsTransparency = true so I just have the sprites over a transparent background (revealing the board below) and using TapGestureRecognizers to effect the sprite animation event handling.

So in IB hierarchy is: VC / UIView / boardView: UIView / skView

Problem is, the Spritekit scene always targets the top level UIView not skView so game pieces are behind the board. Am I missing something simple here?

I'm gonna try placing a child VC where skView is but any assist, if I've missed a trick, would be very much appreciated.

1
why not just adjust the zPosition of your sprites?Wraithseeker
Don't you present the scene using a command like this: "skView.presentScene(theScene)"? What do you mean by "targets"?Narwhal
I am doing exactly as you suggest: var scene : SKScene = GameScene(size: skView.bounds.size) scene.scaleMode = SKSceneScaleMode.AspectFill skView.presentScene(scene)Cliff
...However, the sprites appear in the view behind the boardView and not in the skView. I could replace the board with an image and set it all in a single skView but I thought it'd be more dynamic if I drew it and placed in a view on top. By targets, I mean the scene renders in the UIView nearest the VC when I want it to render in the SKView view furthest from the VC and on top of the other layers. It doesn't seem to want to play.Cliff
I thought that the z-position of sprites worked only within a skView scene layer. So they would not move to be over the top of my drawing layer UIView that, in IB is over the top of the base UIView layer the skView is rendering in. no?Cliff

1 Answers

0
votes

I wish I could see some code, but what you do is create an IBOutlet for your SKView, then have that outlet present the scene, I am currently doing this in an app I am working on, so I know it is doable