2

I am implementing a horizontal carousel-style character selection screen for a game (as per image below).

Image of carousel effect

The app is structured as one main GameViewController presenting different scenes; the CharacterSelectionScene being one of them.

From my research it seems that, although not always advisable to mix UIKit and SpriteKit elements, the best way to achieve the effect is the use a UIColectionView and add it as a subview to the scene. Because it takes care of the some of the animation and bounce effects.

Horizontal scrolling in SpriteKit (vs. a viewcontroller)

However, it's giving me a real headache! Using the post above as an example, I subclassed UICollectionView but I am unable to use the CharacterSelectionScene as the datasource and delegate! This would be ideal as the scene is where the data is loaded in from a plist.

I am currently using my CharacterCollectionView as the datasource and delegate by passing data from the scene via the collection view's init() a la:

collectionView = CharacterCollectionView(frame: customFrame, collectionViewLayout: layout, characterData: characterData)

This works but feels like a bad idea, it feels like a bit of a bodge. Maybe I'm wrong but as a fairly new programmer I'd just like to do this the right way!

Can anyone point me in the right direction? Am I going down completely the wrong path here or is this a perfectly good way to move forward. All advise/pointers appreciated!

JChil
  • 41
  • 2
  • check out this it might be what you are looking for. https://github.com/bwide/CollectionNode – Ron Myschuk Dec 14 '17 at 16:16
  • Thanks, this works well. Much less confusing to implement. However it still doesn't quite match up to the UICollectionView in terms of smoothness. I'll try some tweaking around to see if I can get it any closer to what I'm after. – JChil Dec 14 '17 at 17:38

0 Answers0