Cocos2d-iPhone Programming Sprite Kit

Re-doing Dungeonators

One thing I think all software developers love to do is to make software for “the heck of it.” Hacking something together without having to worry about users, open source community members, and code reviews, is something devs don’t get to do often in these days of test-driven, agile, minimum viable products. Back in 2011 I created an iPhone game just for the heck of it. I wanted to learn about the indy game development process and there isn’t a better way of learning than by doing. I accomplished my mission and uploaded the first version of Dungeonators to Apple’s iTunes App Store in October of 2011. While the game is not very playable, I learned a lot:

  • How to design and implement a realtime game with Objective-C and the Cocos2d-iPhone framework
  • How to create all the art, fonts, sprites, and a spite atlas
  • How to record (or buy) all the sounds and music and use open source tools to transcode audio for a game
  • How to create the mechanics of a game with objects and callbacks while ref counting to manage memory
  • How to test and deploy an iOS game and get something approved in the App Store

Now it’s 2014 and much has changed in the world of indy game development for iOS. Apple’s iOS 7 introduced Sprite Kit which reduces the need for a framework like Cocos2d. Apple also introduced the iPhone 5 and the iPad with Retina, which mean there are four iOS screen resolutions/aspect ratios in common use. Oh, and let’s not forget Flappy Bird and 2048. While writing a hit indy game is still harder than winning the lottery it looks like a couple of people have done it!

Since I’m taking a break between adventures, I thought it would be fun to update Dungeonators for iOS 7 and Sprite Kit. Plus it would be good to make the game universal (available on all iOS devices) and global (available in more than just the United States edition of the App Store). And I should probably make it playable!

The technical part of this plan is relatively easy. iOS 7 is easier to develop with than previous versions of iOS. I can use ARC (automatic reference counting)in addition to manual ref counting. All the music and sound effects should just work fine. My custom Objective-C classes just need some simplifying (I wrote too much code–that’s my bad coding habit). The original Dungeonator’s artwork is all vector-based so rendering it in different resolutions for each iOS device shouldn’t be too hard. Finally, Sprite Kit is remarkably similar to Cocos2d. Porting the scenes, sprites, transitions, and actions will also be easy.

High resolution Dungeonators under development (1136 x 640 pixel rendering)

The hard part is creating a playable game. If you download original version of Dungeonators from the App Store you’ll find it really confusing. How do you play? Where to you touch? What is the goal? I don’t know what I was thinking!

Actually I do know what I was thinking. I was thinking about the inside not the outside. Inside there are classes for characters, strategies, spells, payloads, and matches. Way too much to fit in a casual game. So while I’m porting everything over I’m going to tear out hundreds of lines of code. I’m going to simplify Dungeonators to the point where it doesn’t require a personal demo from me to learn how to play!

I still might not have a playable game but at least it won’t crash anymore!

Nerd Fun

April 1, 2014 Tech News

Google Announces Google++

Google++ users will have access to a social network with encapsulation, multiple inheritance, and polymorphism. Google++ users get the added benefit of UML diagrams and free advice from the Gang of Four (The computer scientists, not the punk band).

Yahoo! Acqui-hires Apple

To ensure it has the right talent for the 21st century Yahoo! acquired Apple today, cancelled the iPhone, iPad, iOS, and all those other tired old projects, and distributed Apple’s engineers to it’s most disruptive technology initiatives, including Yahoo! Mail, Yahoo! Groups, and My Yahoo!.

Facebook Founder Mark Zuckerberg Buys EVERYTHING

Facebook bought everything, the whole shebang, all of existence, and life as we know it, for a combination of cash and stock valued at $1 Quadrillion USD. “Mark promised the universe would remain independent and free of advertising,” Noted The Creator, who now reports directly to Susan Sandberg.

Apple Unveils Apple TV, Which is Apparently, a TV

Tim Cook released detailed of the long rumored Apple TV. According to Mr. Cook, Apple’s super secret TV is a TV. It hooks up to any cable box and is compatible with almost any Ikea entertainment center. Innovations include a power cable with an odd connector and a remote control with no buttons.

Elite Hackers Who Supposedly Fixed Admit They Did Nothing

The co-called elite hackers called-in by the Obama Administration to keep the Affordable Care Act website from crashing admitted, via a blog post on Medium, that while they held many meetings and drew several diagram, the scaling and performance problems with were actually resolved by the software developers who have been working on the project the whole time. “Luckily the developers just ignored us and fixed the bugs they were going to fix.”


Learning Haskell on the Web

(Image source:

Below are websites and such that I’m tracking in my quest to sharpen my FP skills by learning Haskell in my spare time.

  • The Haskell website (where you can download it)
  • A brief introduction to Haskell on GitHub (apparently from a book on Scala, short and sweet)
  • A complete Haskell textbox on WikiBooks (and a great example of a WikiBook)
  • School of Haskell website (hosted by my friends at FP Complete)
  • Guide for setting up Haskell on Windows from Stack Overflow (yes, I have a Windows machine #noshame)
    • Note: The question and top answer are from 2008. Scroll down to the 5th answer from 2013–which is the best one IMHO)

Why should you learn Haskell? Because you only have one one life to live and you shouldn’t spend the majority of it hunting down bugs created by unintended side effects (or intended side effects for that matter) created by programming paradigms that get fuzzy around the edge cases. Life is all edge cases!

Even if you never write production Haskell you can take what you learn from it and apply it to your programming lingo of choice and hopefully write more legible, maintainable, and extensible code.



Huffington Post

Conan Loves HuffPost


Proofreading Your Text with Mac OS X’s Text-To-Speech

I write an almost weekly blog post for HuffPost and I’m terrible at proofreading my own work. I use the text-to-speech function on my Mac to read the text to me. I find I can hear grammar errors in my own work more readily than I can see them. Most word processors and text editors that I’ve found don’t have a specific feature for text to speech. I like to have a short-cut key for this feature so I can review the text, make changes, listen again, and repeat the process without slowing down to find a menu item.

Apple has a great facility in Mac OS X that makes it easy for me to send a selected paragraph to the Mac’s speech service that works with most applications. Well it works with Pages, Chrome, Dictionary, TextEdit, and Scrivener. It doesn’t work with TextWrangler and I have not tested it with Microsoft Word.

The location of the speech service control panel has changed over the years and is a little hard to find in Mountain Lion. (I’m sure it will change in Mavericks too.) But as of today this is what you do:

Go to the Apple menu and choose “System Preferences…” In the System row click the “Dictation & Speech” icon. In the Dictation & Speech panel click on the “Text to Speech” tab. Check the “Speak selected text when the key pressed” checkbox. Whew! That was crazy!

The default key for speaking text is “option-escape” which I can not easily remember or press. For ultimate productivity I set it to a single keystroke (F13) which makes having a full size keyboard rewarding.

Nerd Fun Programming

Getting Xcode and GitHub to work together like besties

Updated for Xcode Version 7.3.1 

Thanks to Jake for pointing out that his blog post needed a little freshening up!

After watching the WWCD keynote I wanted to fool around in Cocoa and Objective-C again. It’s been a while and my Xcode skills were rusty. One task that always seems tricky is getting Xcode’s local git repository to work well with GitHub’s remote repositories. I clicked around, read some docs, did a little Googling, and experimented until I got it to work and in way that works every time.

There are many other blog and stackoverflow posts on this subject but most are either missing a critical step or making it out to be way more complicated than it really is. That’s the problem with Apple magic: Sometime’s they design away the details to a point that you really don’t know what is going on.

The best tutorial on Git, Xcode, and GitHub for the white belt hacker is here:

But the part on connecting your local Git repository created and managed by Xcode to your remote GitHub repository is a little brief and lacks detail that might trip you up. Here is all you need to do to get Xcode and GitHub to play nice…

  • Create your Xcode project with a local Git repository and write some code
  • Commit your changes locally (File > Source Control > Commit…)
  • Create your GitHub remote repository on GitHub but do not initialize it and do not add a file!
    • Note: You can give that remote repository any name you want, I gave it the same name as my local git repository because I’m lazy
  • Go to the Source Control menu and and choose the second item with the name of your repo. This item leads to a popup menu. Choose the last item of that popup menu which has the name of your repo and word “configure”
  • In the configure dialog choose the Remotes item
  • Click the + button and choose “Add Remote” to associate a remote repo
  • In the Add a Remote dialog box you have two fields to fill out
    • In the name field enter the name of the GitHub repository you just created
    • In the location filed paste the “HTTPS” URI from GitHub for your repo
    • It will look like this:
  • Now you have a connected local and remote repository 🙂
  • Go back to the Source Code menu and choose Push…
    • A dialog box pops up with a drop down menu
    • Choose the only option you can which will be something like your-repo-name/create
    • Click the push button
    • Enter your user name and password in the dialog box that appears

You Win!!

Remember to check “Push to remote” in the Commit dialog box so you check in your code both locally and remotely.

Extra Credit:

I use Two Factor Authentication and I had to turn it off to test this. That made me a little nervous and I immediately turned Two Factor back on.

However you can generate a Personal Access Token so that that you can push to GitHub from Xcode and keep Two Factor on!

  • Log into you GitHub Account and go to Settings > Personal Access Tokens
  • Click the Generate New Token button
  • Give the button a description such as “Xcode Repo-Name”
  • Check the least amount of scope needed to commit code remotely: “Repo”
  • Click the Generate Token button at the bottom.
  • Copy the token (which is a long string of numbers)
  • Back in Xcode go to Preferences > Accounts and choose your repo under the list of repositories.
    • The Address field will contain the HTTS URI you entered earlier
    • The Description is the name of your repo
    • Authentication should be set to User Name and Password
    • User Name should be your GitHub user name
    • In the Password field paste token

Boom! Now you can commit remotely with Two Factor Auth in full effect!


Huffington Post

HuffPost has 250 Million Comments

Screen cap of my appearance on HuffPost Live to announce we got over 250,000,000 comments.

More info here at my blog post on the announcement at


Everyone should learn to code

I was on a HuffPost Live segment and got a chance to discuss why learning to code is something everyone should do!

Movement Grows To Cultivate Computer Programming

That’s me on HuffPost Live!

And I have two HuffPost blog posts talking about coding and drawing and why you should learn to do both.


Opps! Errors in Google’s Chrome Extension Tutorials

I don’t know why, but I got interested in writing a Chrome Extension. Yeah, I know, like 3 years too late. I figured it would just take an hour and I might learn something about well designed plug and play component architecture. I quickly found the Getting Started tutorial. The screen shots were a bit out of date but the instructions were clear and simple. After following the tutorial the example extension (kitten photos from Flickr) failed to display images and failed to post any errors to the debug console.

So I went the Debugging Tutorial but I could not get my extension to load in the debugger.

Fooling around I could make text to and images display in the example extension’s popup window but the example code, provided by Google, failed to work. Did the Flickr query API change? Was a bug introduced in a Chrome update? Is my computer broken? A glitch in the matrix?

I love that feeling you get when you’re debugging utterly simple code and completely lost: “It should work and when I figure it out I will feel like an idiot!” (because generally it’s a missing a “}” or some other typo).

But this time it wasn’t me! It was Google’s tech writers.

First, if you want to debug a Chrome extension do not follow the instructions: Right-click the Hello World icon and choose the Inspect popup menu item.

Instead do this: Left-click the Hello World icon so the popup appears and then right-click the popup window! (Unless you are left-handed like me and you have to right-click where the world says “left-click.”)

Clicking with the “other mouse button” (the handed-neural way to say “right-click”) on the extension’s window brings up a context menu that let’s you inspect the extension and load its code and resources into a Chrome debugging window.

Second, if you want to see the kittens, change this line in popup.js:"GET", this.kittensOnFlickr_, true);
to the much more effective:"GET", this.searchOnFlickr_, true);
The function kittensOnFlickr_ is never defined. The function searchOnFlickr_ is defined instead. The kitten look excellent when they finally appear!
Sometimes when looking through a tutorial I find errors like this and wonder two things: Am I the only one who actually reads and runs programming tutorials? Is this an intelligence test?
Given that Chrome extensions are no longer a hot technology it probably doesn’t matter 🙁