Build a grid level for a game with SpriteKit and SWIFT
I’m searching the best way to build the levels for a game :
- The game will be composed with many levels, each levels will be
- You’ll play an object (here the star), which is in movement
on a grid.
- The object can move only to the bottom, it cannot go back.
- A level is composed with many cases, each cases will have a different
- My level will have a background, width of the screen, but
the height will depend on the level, I suppose many times the height
of the screen.
- The background moves depending on the object movements
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?
Solutions Collect From Internet About “Build a grid level for a game with SpriteKit and SWIFT”
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
- cover the square background
- make an effect like explosion
- change color of a square instead of general square colors
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:
to use it:
CGRectIntersectsRect(<#T##rect1: CGRect##CGRect#>, <#T##rect2: CGRect##CGRect#>)
- How to run and debug unit tests for an iPhone application
- How to print call stack in Swift?
- How to Get time difference in iPhone
- Realm issue with Swift 3.1
- Base64 Encoding for NSString
- Generate random alphanumeric string in Swift
- + called within transaction
- iPhone6 (no display zoom mode) UIMenuController truncated
- Animation of CGAffineTransform in iOS8 looks different than in iOS7
- How can I turn off indexing in Xcode 5.1.1
- How to display the emoji and special characters in UIlabel and UItextviews?
- Is it possible to have a Game Center “LowestScore” Leaderboard?
- How do I make a SKSpriteNode that does not respond to touch if it's pixels are transparent?
- How to handle cleanup of external data when deleting Core Data objects
- Show Playlist-folder in iOS App