kodeco.com Forums

How To Make a Game Like Space Invaders with Sprite Kit and Swift Tutorial: Part 2

Learn how to make a game like Space Invaders using Apple's built-in 2D game framework: Sprite Kit!

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1163-how-to-make-a-game-like-space-invaders-with-spritekit-and-swift-part-2

Thanks for the great tutorial. This one was another fun project.

One request for all RW writers: If you could made a side note where you’d use a different method for a distribution quality app, it would be very helpful for someone like me who is aspiring to release apps in the future. For example, in this tutorial, the animation of invaders do not necessarily match the movement because there is nothing making sure they are synchronized. It is perfectly acceptable for the purpose of this tutorial, and even preferred for the purpose of introducing readers to animation. But for apps distributed online, another method (e.g., swapping texture before each move, rather than relying on SpriteKit animation) is probably preferred. RW has been a great source of information for my quest to write my own app, but I run into this problem sometimes — I learn a new trick, start implementing it in my own project, then find out it is not robust enough.
But you guys have taught me so much, and I appreciate what you do. I have read “iOS Games by Tutorials” cover to cover a few times already, and the book is disintegrating into pieces. :smile:

It looks like there is a minor holdout from Swift 2 near the bottom of part 2 of this tutorial.
In the final stages, where the speed is being adjusted - the “before” code has you inserting the new lines right above



case .Right:
  if (CGRectGetMaxX(node.frame) >= node.scene!.size.width - 1.0) {
    proposedMovementDirection = .DownThenLeft
    // Add the following line
    self.adjustInvaderMovement(to: self.timePerMove * 0.8)
    stop.memory = true

I double checked part1, where this code is originally entered, it does have the correct update - it shows

case .right:
if (node.frame.maxX >= node.scene!.size.width - 1.0) {
proposedMovementDirection = .downThenLeft

    stop.pointee = true

Thanks for the very informative and fun tutorial :slight_smile:

Hi, great tutorial. I remember this game when it came out … yes, I’m that old. I’m going to try and put the manual direction controls back in. The accelerometer action is really pretty awful, and in one stage, the ship went floating off to the top of the screen. Nothing I did would bring it back down - until the game ended of course.
I’ve run it on my iPhone SE, and it doesn’t produce any sound either. Although it does on the desktop (Mac Mini).
But a great tutorial none the less. 10.3.2, Swift 3. Now there’s an idea. I’ll put it on the Mac, left and right arrow keys. space bar firs. Just like the old days…


Great tutorial - I’ve learnt loads from it. Quick question tho - Ive added in a UIImage View as a subview programatically - how do I sent this to the back of the space invaders etc. At the moment it is sitting on top.

Thank you.

This tutorial is more than six months old so questions regarding it are no longer supported for the moment. We will update it as soon as possible. Thank you! :]