Getting Started with Developing SpriteKit Games for iOS
Articles for getting starting developing SpriteKit games on iOS.
In a typical iOS app, you build your screens either with UIKit's
UIView and possibly storyboards or you might try SwiftUI and build out a
View based on an
Those kinds of apps often have scrollable lists of data, forms, tabs, or hierarchical navigation suitable for a to do list or an email client.
But games are something very different.
Each node we create in the scene can optionally have a
physicsBody associated with it. If it does, then it will have velocity and acceleration and forces, like collisions and gravity, will have an effect on them.
There are some common patterns, so it's useful to extend
SKPhysicsBody. Here are two functions that are meant to be used when you create a physics body.
When you are creating and analyzing vectors in SpriteKit, it's useful to think of them as an angle and a length, not just as a
(dx, dy) pair.
Here is an extension that helps you do that.
In the previous article, we set up the visible elements of pong and the basic physics that governs the movement of the ball.
At the end of the article, we had the ball bouncing off the walls and paddle and moving in a gravity-free, drag-free environment.
The next thing we'll tackle is letting the players move the paddles.
If you play the game, you'll see that once we miss the ball, it goes off the screen and, well, then nothing happens.
We want the miss to be detected, and then for a new ball to be placed in the center so we can continue.
Let's do that.