1

First - apologies for starting a new question but I don't yet have the required reputation to comment on the original.

I have implemented the scroll view from here https://github.com/crashoverride777/SwiftySKScrollView and this question ScrollView in SpriteKit. Everything works great, until I try to resize it or move it. I'm hoping to have two separate scroll views next to each other (which doesn't seem like it should be too difficult) but i cannot move the first SwiftySKScrollView to one side.

I've worked out that the issue happens as soon as I change any of the frame parameters in

scrollView = SwiftySKScrollView(frame: CGRect(x: 0, y: 0, width: CGFloat(frame.width), height: frame.height), moveableNode: moveableNode, direction: .vertical)

After I change the parameters (and that's all I'm doing - even just dividing the height parameter by two alone causes the problem), the scroll view shows up exactly how I want it but the children no longer respond to touch.

Thanks for any help, I really appreciate it.

Community
  • 1
  • 1

1 Answers1

0

Thanks for using my helper. Here are my thoughts

1) This helper is actually quite old and I personally no longer use it for my own projects. I still maintain the GitHub repository but its not the most elegant solution or something I would recommend unless its for the simplest of menus. I did mention this in the instructions.

2) It is not designed to have 2 smaller scroll views next to each other. So I would not even bother trying to continue. Your end result would also be clunky and involve a lot of error prone code.

3) In general you would want to avoid using UIKit in SpriteKit.

4) UICollectionViews are now pretty much the only UIKit stuff I might use in my SpriteKit projects (e.g large level select menus) because they offer certain conveniences (scrolling, cell reuse etc) that would be very hard to recreate in SpriteKit.

5) First try doing it all with SpriteKit APIs (SKLabelNodes, SKSpriteNodes, SKNodes etc).

Have a look at this for an example

https://codedump.io/share/etvt4SwQI6iR/1/how-to-create-a-vertical-scrolling-menu-in-spritekit

6) If point 5 is not an option you will probably have to implement 2 UICollectionViews. The problem here is that

a) you will have to learn about UICollectionViews if you haven't used them before

b) You have to either create them via Storyboards which can be tricky if you haven't used Storyboards before. It is also than quite difficulty to implement them in your SpriteKit scene.

c) Create them in code like SwiftySKScrollView which can also be quite tricky if you haven't used them before.

Hope this helps

crashoverride777
  • 10,581
  • 2
  • 32
  • 56
  • Ah ok thanks for letting me know. Struggling to find an example of someone having done it well as you suggest with the SpriteKit APIs, but determined to have a go after what you've said. – user1836346 Mar 30 '17 at 18:05
  • No problem. What you want to achieve is quite tricky, especially because you are making a SpriteKit game but want/are using UIKit APIs. Have a look at this, not sure this will help but this is how you could do it in sprite kit. https://codedump.io/share/etvt4SwQI6iR/1/how-to-create-a-vertical-scrolling-menu-in-spritekit – crashoverride777 Mar 30 '17 at 18:16