iCarousel no Kit Sprite

Explicação

Estou tentando criar um menu de seleção de personagens semelhante ao menu da Crossy Road (como você pode veraqui) Então eu achei issoiCarousel, o que me ajudaria com tudo isso, mas tudo o que leio fala sobre implementá-lo em umViewController, que não é o meu caso. estou a usarGameScene e não encontrei nada falando sobre isso. Existe alguma maneira de implementá-lo no meu jogo? ou mesmo outro efeito semelhante ao menu de seleção de personagens que mencionei acima?

Tentativa (beyowulf)

Você pode fazer o downloadaqui.


GameScene.swift

import SpriteKit

class GameScene: SKScene {

    var show = SKSpriteNode()
    var hide = SKSpriteNode()

    func showCharPicker(){
        NSNotificationCenter.defaultCenter().postNotificationName("showCharPicker", object: nil)
    }
    func hideCharPicker(){
        NSNotificationCenter.defaultCenter().postNotificationName("hideCharPicker", object: nil)
    }

    override func didMoveToView(view: SKView) {
        /* Setup your scene here */

        print("didMoveToView")

        show = SKSpriteNode(imageNamed: "show")
        show.anchorPoint = CGPointZero
        show.position = CGPointZero
        addChild(show)

        hide = SKSpriteNode(imageNamed: "hide")
        hide.anchorPoint = CGPointZero
        hide.position = CGPoint(x: self.frame.width / 2 - hide.frame.width / 2, y: 0)
        addChild(hide)
    }

    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

        for touch in touches{

            let location = touch.locationInNode(self)
            let node = nodeAtPoint(location)

            if node == show{
                print("show")
                showCharPicker()
            }
            else if node == hide{
                print("hide")
                hideCharPicker()
            }
        }
    }
}

GameViewController.swift

import UIKit
import SpriteKit

class GameViewController: UIViewController, iCarouselDataSource, iCarouselDelegate{

    var squaresArray : NSMutableArray = NSMutableArray()

    @IBOutlet weak var carousel: iCarousel!

    deinit{
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }

    func showCarousel(){
        self.carousel.hidden = false
    }
    func hideCarousel(){
        self.carousel.hidden = true
    }

    override func viewDidLoad(){
        super.viewDidLoad()

        // Configure iCarousel
        carousel.dataSource = self
        carousel.delegate = self
        carousel.type = .CoverFlow
        carousel.reloadData()

        self.carousel.hidden = true

        // Register showCarousel and hideCarousel functions
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.showCarousel), name: "showCharPicker", object: nil)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(self.hideCarousel), name: "hideCharPicker", object: nil)

        // Configure view
        let skView = SKView()
        self.view.insertSubview(skView, belowSubview: self.carousel)
        skView.frame = self.view.bounds

        // Additionals
        skView.showsFPS = true
        skView.showsNodeCount = true
        skView.ignoresSiblingOrder = true

        // Configure scene
        let scene = GameScene(size:self.view.bounds.size)
        scene.scaleMode = .ResizeFill
        scene.size = self.view.bounds.size

        skView.presentScene(scene)
    }

    //iCarousel
    override func awakeFromNib(){
        super.awakeFromNib()
        squaresArray = NSMutableArray(array: ["square1","square2","square3"])
    }
    func numberOfItemsInCarousel(carousel: iCarousel) -> Int{
        return squaresArray.count
    }
    func carousel(carousel:iCarousel, didSelectItemAtIndex index:NSInteger){
        //self.hideCarousel()
    }
    func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView{

        var itemView: UIImageView

        if (view == nil){
            itemView = UIImageView(frame:CGRect(x:0, y:0, width:200, height:200))
            itemView.contentMode = .Center
        }
        else{
            itemView = view as! UIImageView;
        }

        itemView.image = UIImage(named: "\(squaresArray.objectAtIndex(index))")
        return itemView
    }
    func carousel(carousel: iCarousel, valueForOption option: iCarouselOption, withDefault value: CGFloat) -> CGFloat{

        if (option == .Spacing){
            return value * 2
        }
        return value
    }
}
O que está acontecendo:


Desde já, obrigado,
Luiz.

questionAnswers(1)

yourAnswerToTheQuestion