1
votes

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

1

1 Answers

0
votes

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