I’m searching the best way to build the levels for a game :
For now, I’m working on a little prototype, just to learn.
After reading many tutorials, my idea is to create x squares (diamond-shape) using SKSpriteNode. And to identify the squares with identifiers.
I don’t know if it’s a good solution in terms of performance? They will be a lot of squares in one level. I don’t realize :)
Are we limited with the numbers of node in one scene?
I think it's not necessary. You can also use a single SKSpriteNode
background populated by squares CGPath
's and you can make a very fast game if you want to increase difficult levels. You can organize your "functional" part of game by working with each CGPath
and when you must change a square in this case you can create a square using the CGPath
that represent that square, give to it a name based for example to an index to easily understand who it is, using the CGPath
involved and use this SKSpriteNode
to:
P.S.: I've seen you want to create a scrollView, there is a nice Spritekit library in swift called CustomScrollView
here that can be useful , it's simply to use:
scrollView = CustomScrollView(frame: CGRect(x: 0, y: 0, width: self.frame.size.width, height: self.frame.size.height), scene: self, moveableNode: moveableNode, scrollDirection: .Vertical)
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, scrollView.frame.size.height * 3) // makes it 3 times the height
view?.addSubview(scrollView)
Update: about your comment, the answer is yes: when you work with a path you work with a group of elements organized in points (take a look at this post to understand how).
You can use the native:
CGPathContainsPoint(<#T##path: CGPath?##CGPath?#>, <#T##m: UnsafePointer<CGAffineTransform>##UnsafePointer<CGAffineTransform>#>, <#T##point: CGPoint##CGPoint#>, <#T##eoFill: Bool##Bool#>)
or use this:
CGPathGetPathBoundingBox(<#T##path: CGPath?##CGPath?#>)
to use it:
CGRectIntersectsRect(<#T##rect1: CGRect##CGRect#>, <#T##rect2: CGRect##CGRect#>)