Xerra's Blog

Drunken coder ramblings

Swift 2 – The future of IOS development. —

With iDef up on the appStore with no – aparent – bugs found as yet, Aaron and I are both looking into Swift for future development of our games. iDef was written completely in Objective C, with the use of Cocos2D as the framework for all the funky stuff.

We started tinkering with Swift in it’s V1.2 build and have now had to adjust to the shiny 2.0 that has just been released with the new XCode build. This coincides with the switch to open-source (A seriously cool decision) as well as also letting developers build to devices rather than be restricted to just the IOS simulator if they didn’t have a developer licence.

As a development team we’ve paid for a joint licence to be able to work on projects and test direct on devices but there’s no bitterness here because it was always going to happen at some point. With this change people can now write their own software and put it onto their Iphones or Ipads as they wish. Or they can even have other people link their devices to the development machine and give their work away as well. Apple obviously don’t get a sale out of this but who’s to say that the app would have gone to appStore anyway? People do develop stuff just for themselves and Apple have hopefully twigged that it’s unfair to expect that everything developed on any machine that’s been built by them should get them their slice of the pie. Common sense. You couldn’t imagine the OSX or Windows market ever surviving if there was only one store that you could get software from. Piracy concern or not.

But, I digress. Back to what we’re up to at Dexterity Design now. The new game we had in mind to start work on is still a focus point but it’s on the back burner for now, as we’re both tinkering with prototypes to work out how to use SpriteKit and Swift 2 to good effect. It’s pretty simple to knock up funky particle effect demo’s and small stuff like that, but the whole game building process with both a new language, and a framework, isn’t going to happen overnight.

So Aaron is tinkering with a simple maze-game kind of Pacman-ish – but not enough to risk being sued. And I’ve been looking at converting the last game I completed onto the iPad instead. It’s not likely we’ll throw out Aaron’s work due to the risks of legal issues but if I get Gravity Force into some kind of state where we’re both happy with it, then we might have a tinker with the appStore again and just give it away for anyone who wants to have a play. It’s mainly if we think the quality is up to scratch wether we do that or not.

The idea to do this as a starting project was because of another idea we considered, which would potentially bring iDef onto OSX at a later date. Unlike Gravity Force (which was originally written in Blitzmax just for Windows), iDef was written specifically for IOS devices and uses a proper framework for just this. So a conversion to Mac would mean a new engine for all the graphic stuff at the very least, even if a lot of the background gameplay code could be relatively easilly adapted for the big screen. Possibly the whole game could be emulated direct into an OSX window with a bit of clever coding but this would feel a bit hacky to us. And if we were looking at selling it on OSX (and potentially Windows at a later date) then it needs to be done well. We’d be opening ourselves up to the issue of piracy then, just like every other bit of software that’s ever been released, but it’s a small price to pay for possibly another slice of the pie. Demo distrubtion on it’s own could end up being a big incentive to potential buyers just for starters.

Gravity Force, on the other hand, was written in a language that can cross-compile direct to either Windows or OSX. So, when I bought myself a Mac for the first time, one of the first things I wanted to do was get the games I had written working on that platform as well. Indeed, just like the language promises, I could just recompile the project and have it running on my new machine. I put both the Windows and OSX versions up for free download in my first post of this blog as a result.

Since this I have gone back to both builds once just to fix a very minor bug and update the OSX build to work better with bigger screens. It’s not perfect even now, because I had other things to work with, but the project was developed on a crappy small screen monitor on my PC and I now work from two huge monitors with massive resolutions available to me. Originally Gravity Force was hard coded to work on 1024 * 768 only, and there was no option to rescale anything.

Naturally the fact I used to write games like this and hard code resolutions really disturbs me, now that I’m taking game development more seriously.

Where I might use something like this in Blitz:-

Graphics 1024, 768,32

Draw Image Logo, 600, 200


I would be more likely to use something like this in Swift:

earth.position = CGPoint(x: size.width * 0.5, y: size.height * 0.1)



CGPoint is the part of spriteKit which knows what device you’re running on, and what size of pixel display it has available as a result. So calculations of where to put things are all relative to that. On an IOS device the cordinates for 0,0 are also at the bottom left, rather than the top, so that also makes it more interesting to work with. Today I have been playing (and failing) with the XCode .SKS system for setting up a scene with images before doing it the old fashioned way, just like I used to do it with Blitz actually. Perhaps that’s why it made more sense.

I could also mention that I spent twenty minutes trying fruitlessly to work out why I couldn’t use a line like: Println(“Display initialised correctly”) anymore. Reading the patch notes finally told me that the command had been merged with Print now to make things easier.

Yes. Easier if you read the manual, I suppose. I’m sure there’s a lesson to be learnt here.

So, to sum up. We’re both working. More like tinkering, I suppose, but there’s some semblance of productivity, and we’re hoping for great things when we kick off on a new project. Exciting – and hopefully – productive days to come.

Thanks for reading and please keep an eye on the website for proper updates from us, rather than just my ramblings.


You can click here to jump straight to the website.


Categorised as: Development | SpriteKit | Swift

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.