1

In a regular project, adding a scrollView is easy enough:

https://www.youtube.com/watch?v=oQZ4mQpHXCo

But in a spriteKit project this approach doesn't work (as far as I know) since you can't add you nodes to the UIView (at least I didn't get it to work), resulting in a scrollable view on top of the nodes, rather than the nodes being in the scrollable view.

In my project I have several nodes drawn out as a game board with tiles. I would like to be able to scroll on all directions by dragging across the screen the direction I want to go.

I read this SO question and looked at the answer:

Scroll View in SpriteKit

But there's a broken link that could perhaps be useful, and the scrollKit honestly seems a bit hard to grasp, even though I have played around with it a bit. So, what approach should I take? Is there some way I can use a UIScrollView in a viewController or is the scrollKit the way to go about this? And what about touchesMoved? Can this be used to scroll the screen? I also looked at this:

ScrollView in SpriteKit

But don't seem to be able to get it to work properly.

  • Probably the most natural way to move the view around in SpriteKit is to have an SKCameraNode and have your various UI controls/gestures control that. https://developer.apple.com/documentation/spritekit/skcameranode – bg2b Nov 29 '19 at 12:39
  • Nice, I hadn't thought about that. Thanks for the tip! – screenMonkey MonkeyMan Nov 29 '19 at 12:55

0 Answers0