Group Group Group Group Group Group Group Group Group Forums

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

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

Hello, when I downloaded this tutorial on Xcode, it didn’t build. Instead, it gave me six errors. I don’t know if that is because I didn’t put the code in, however, when I tried to simulate the Gamescene.swift, it opened up an iphone screen instead without the opening screen as shown. If you could please help, I would appreciate it. Thank you.

Hi @navytrident933, I’d love to help you get this working. What version of Xcode are you using? This tutorial has been updated for Xcode 7.3. Also what are the errors you are getting?

The Xcode version I am using is version 7.1. I just realized that myself and I am updating it right now. I think that might have been the reason as to why I was getting the errors. I didn’t realize it had an update. Thank you for letting me know. The errors I was getting were in the gamescene.swift file and they were syntax errors such as missing argument in parameter and the expected ‘,’ separator error. Also the expected expression in list of expressions.

Okay, getting Xcode updated to 7.3 should solve this then. Let me know if it works after the update if not I’ll see how else I can help you get this working. :]

Great tutorial! Small bug in the text: “Now replace the println statement in processUserMotionForUpdate (right after comment // 4) with the following:” should read “Now replace the print statement in processUserMotionForUpdate (right after comment // 4) with the following:”.

As an aside, I like that Swift ditched strangely non-camelCase println with print. I suspect that println reflects Java influence.

Great tutorial. Has someone an idea for realizing the invader movement sound like in the original game?


   // 4
    for _ in 1..<kInvaderRowCount {
      // 5

Actually be referring to ‘kInvaderColCount’ ?

Since both the row and the column counts are identical, the result is the same in this case, but it would have made the logic of placing the sprites on the grid easier to understand for me.

1 Like

Good catch! I updated the tutorial so it’s not confusing for others in the future.

Minor syntax change:

Add the following code to createContent() right before the setupInvaders() line:
physicsBody = SKPhysicsBody(edgeLoopFromRect: frame)
The new code adds the physics body to your scene.

XCode 8.2.1 helpfully informed me that the new syntax is:

physicsBody = SKPhysicsBody(edgeLoopFrom: frame)

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! :]