1

I am trying to create a "Store" menu for my game with a vertical scrolling list of items (each line with a label, a logo and a button).

I found this topic which was really interesting : How to create a vertical scrolling menu in spritekit?, but I end up with elements from my scrollview that appears on all screen. I followed precisely the above topic.

I would like to make something like the "Candy Bank" in the Candy Crush game, meaning that I have a store menu "popup" which appears (a SKSpriteNode) and I would like my items to be hidden when scrolled out of the menu. Currently the items still appears on all screen when scrolled:

What I have now:

enter image description here

and what I am looking for:

enter image description here

Community
  • 1
  • 1

1 Answers1

0

Not sure why people insist on combining UIScrollView and SpriteKit in such a way, it kills performance. I would recommend either doing everything in UIKit, or doing everything in SpriteKit.

Benefit of doing it in UIKit is you get constraints to nicely place your buttons.

Benefit of doing it in SpriteKit is you do not have to maintain another view, and can stay within the scaling factor of your other sprites.

Now to do it in SpriteKit is really easy, You basically set up a SKCropNode to act as your container to hide anything from going outside the container, and inside of it you add a bigger node that you scroll with, with a combination of SKActions and other things to create a smooth effect. Here is a great example of how to do it, that is better than any code that I can post. https://github.com/JenDobson/SpriteKitScrollingNode/tree/master/SpriteKitScrollingNode

Knight0fDragon
  • 16,609
  • 2
  • 23
  • 44
  • Apple suggests Sprite Kit and UIKit play well together, and named SKView as though it can be underneath UIViews at any time. There are no official warnings about the terrible performance. Everyone new to Sprite Kit will then assume they're supposed to be used together. – Confused Apr 04 '16 at 19:47
  • Sprite Kit and UI Kit can be used together, and when creating quick little apps, it does make life easier, When you get into more complex situations like what the OP intends to do, you will notice performance dropping when using UIKit elements as opposed to Sprite Kit elements, especially on devices like the 4s or iPad 2 (Which is still supported as of iOS 9) – Knight0fDragon Apr 04 '16 at 20:08
  • See other comments on other question. This issue affects modern devices, too. And probably always will as it seems Sprite Kit and Scene Kit are WAY down the list of Apple priorities. – Confused Apr 04 '16 at 20:09
  • Wait, are you agreeing with me? – Knight0fDragon Apr 04 '16 at 20:10
  • Yes, very much so. And then some. – Confused Apr 04 '16 at 20:35
  • Thank you, I will try this solution tonight. It was not really obvious for me that a mix of SpriteKit and UIKit would not work well together :) (as you have noticed I'm creating my first app in Swift...) – CharlyStudio Apr 05 '16 at 12:15