Ok, so I implemented a scrollview by using this method:
How to create a vertical scrolling menu in spritekit?
Now when I launch the scene it doesn't display anything except a black/ grey background
Here is the code I have used in the menu scene:
import Foundation
import SpriteKit
import UIKit
//let kMargin: CGFloat = 40
//var backButton = SKSpriteNode()
//var selectButton = SKSpriteNode()
var moveableNode = SKNode()
var scrollView: CustomScrollView!
private var imageSize = CGSize.zero
var sprite = SKSpriteNode()
class Menu: SKScene {
func didMoveToView() {
addChild(moveableNode)
scrollView = CustomScrollView(frame: CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height), scene: self, moveableNode: moveableNode)
scrollView.contentSize = CGSizeMake(self.frame.size.width, self.frame.size.height * 2)
view!.addSubview(scrollView)
sprite = SKSpriteNode(color: SKColor.redColor(), size: CGSize(width: 50, height: 44))
sprite.position.y = CGRectGetMidY(self.frame) + self.frame.size.height
moveableNode.addChild(sprite)
}
}
It might be really obvious but I can't seem to see it.
Try this for the sprite, I made a mistake in the other question, it should be - self.frame.size.height, not +.
Check my gitHub project
https://github.com/crashoverride777/Swift-2-SpriteKit-UIScrollView-Helper
The sprite position is not right, not sure where exactly you want it. I do the following and the sprite show up on the view.
or