Category: Swift game development

Swift Game development, Part 3

I’m happy to report that although I did not have much time this weekend to devote to game development, I was able to create a new SpriteKit Scene file, lay down a new tile map grid, and position my character sprite in the new level.


The player sprite I made with Aseprite which is a very cheap yet very capable sprite editor.   I had to watch this video on how to make it transparent.  Teach yourself!

Swift Game Development, Part 2, fading a SpriteNode that doesn’t want to fade

Today I learned about the “isPaused” instance property of an SKNode object.   The problem I encountered was that after showing some informational text, such as when your player sprite “talks” to a non-player character (NPC), you want to fade the text out.  The code works fine on iOS, but the MacOS program refused to fade the text.

When you want to programmatically create a sequence of actions for a sprite node to execute, Swift and the SpriteKit provide a plethora of ways to accomplish this.   The easiest way is to create a few SKActions and then chain them together with sequences and finally run them:

        let wait:SKAction = SKAction.wait(forDuration: waitTime)

        let fade:SKAction = SKAction.fadeAlpha(to: 0, duration: 0.5)

        let run:SKAction = {

            self.infoLabel1.text = ""

            self.infoLabel2.text = ""

            self.infoLabel1.alpha = 1

            self.infoLabel2.alpha = 1

            self.speechIcon.alpha = 1

            self.speechIcon.isHidden = true


What I discovered was that the run action was not executing.   After much reading, I found that the isPaused property on both the labels and the parent of the labels was “true”.   Very strange.   I did not find out why the nodes were paused, but when I added a check on the parent to see if it was paused and then toggled it if it was, the “run” sequence was able to execute:

        let seq:SKAction = SKAction.sequence([wait, fade, run])

        let seq2:SKAction = SKAction.sequence([wait, fade])

        if(infoLabel2.parent?.isPaused)! {

            infoLabel2.parent?.isPaused = false   //the fix!


Thank you Stack Overflow, you’re the best pair programmer ever!        


SpriteKit game development – Part 1


Here’s a new series that actually began during Christmas holidays of 2017.  I had bought a shiny new MacBook in the Spring of 2017 so that I could get serious about iOS and MacOS development.   I studied several books and online tutorials on Objective-C and a little bit of Swift.  Fast forward to Christmas where I came up with my idea for writing a game that I’ve always been meaning to write.   This would be my third game.   I wrote a C++ game in the 1990s that was left unfinished.   My ambitions were too grand.   Here’s a shot of the gameboard in brilliant VGA.  Yes…DUNE!

just the board

Years passed and the advent of .NET presented a learning opportunity.  I would create a tile based Dungeons and Dragons homage to Ultima III.    I wrote this first in VB.NET with a proxy wrapper into the DirectX 2D Libraries.   I then ported it to C# targeting native DirectX libraries.   Unfortunately I don’t have a screenshot of that game and the libraries are no longer easily available.   I spent a lot of time on it and yet abandoned it as well.

The concept for the new game would be set in the Frank Herbert Dune universe.   I wanted to use the Traveller RPG game rules, with a mixture of Dungeons and Dragon’s Gamma World.   Mixed in would be a dialog based “choose your own adventure” plotline similar to Knights of the Old Republic game for XBox (awesome, awesome game).  I decided to use Apple’s Swift language so that I could learn a new skill and develop my portfolio on GitHub.

So, I studied and completed this course:    I recommend this site.   The tutorial teacher, Justin Dike, has a great sense of humor, easy disposition and very fun set of courses.

After finishing the tutorial, which was about 55 videos about 16-25 minutes each consisting of about an hour a video (watch, pause, write code, test, debug), I was ready to begin.

Using to track my issues in a Trello like interface Jira board.  I’m already having to adjust my sprint because I’m behind!   It’s amazing that free resources like this are on the internet.

Using Articy (available via Steam) to do my storyboarding.   I bought it for $100, which I thought was super cheap.   When I get further along in my game engine I’ll start designing the flow of the game with this pretty impressive application.

I created a GitHub repo and initialized it with the iOS game kit created from the tutorial.  Then I created a develop and a feature branch.   Check it out here:

The first step was to convert the iOS project to a MacOS target.  Even though this article used Obj-C (which I studied last year), the directions were applicable to Swift projects, and I was very grateful:     That took a few hours to tweak and get the new View (SKView) hooked up to the new build target.

The next step was to comment out all of the UIKit references from the iOS project and retrofit them with mouse and keyboard events.   That’s what I’m currently working on.  It’s difficult translating the iOS touchesBegan and touchesEnded to desktop events.  There isn’t a lot of documentation on desktop SpriteKit game development, but I’m relishing the time spent.

Stay tuned for my next update in the series.