Recently I received a few comments and e-mails stating that the beginner’s game programming tutorial featured on this site had issues when running with Xcode 4. I decided to test things out, and had no issues when running the tutorial in Xcode 4 with the latest release version of the SDK.
You can see a screenshot of the game running in Xcode 4 and the simulator below.
The issues may have to do with some still running an older version of Xcode, possibly a beta version. Be sure to update to the latest version available in Apple’s developer website, and if you don’t have access to download the latest version of Xcode 4 you can find it available in the app store for $4.99 here.
If you still receive an error when running the tutorial even wit the latest version of the SDK, please state the error within Xcode.
I have had several requests for updates to the iPhone action game programming tutorial, and among them was an update for retina display support. So here is the process step-by-step for those looking to add retina display support to a game made with the Sparrow Framework.
This update goes through the process of creating the new images for the game, and updating the source code so that the images display at high resolution on the retina display.
Fortunately the Sparrow Framework makes it very easy for us to do this, and handles most of the required programming automatically.
You can download the project files leading up to this tutorial here.
You can download the project including the HD images and retina display support here.
For those who prefer Github you can find the project here, the completed project is in the 7-BalloonGameTutorial folder.
Step 1 – Making The Images
Since my initial images were created for the smaller iPhone display size I needed to scale them up to twice their original size.
I decided to use a tool called SmillaEnlarger to do this, a free open source tool that uses a fractal algorithm to scale up images. In my testing it has actually done better on the types of images (non-photos) that I need to scale up, and the end result looks considerably better than using any of the filters built into Photoshop. I have even seen it stated that SmillaEnlarger provides better results than expensive Photoshop plugins.
You can find SmillaEnlarger here.
You simply drag and drop the images with enlargement selected and a scale of 200%. In order to use the larger display support of the Sparrow Framework you will need to add @2x to the name of your images.
In my settings with SmillaEnlarger for non-photographis I simply turned all the extra adjustments down to zero.
Do that for each image in the project. After doing that I suggest re-saving the images after opening them in preview, not essential, but SmillaEnlarger tends to make oversized files.
Step 2 – Add Images Into The Xcode Project
For this step you can simply drag all the created images into the Xcode project under resources where all the original files are.
You can also add the images by ctrl-clicking and then selecting add resources, select the images, and import them into the project.
Step 3 – Turn On High Resolution Support In Game
The Sparrow Framework simply requires you to add one line of code at this point into the applicationDidFinishLaunch: method of your app delegate.
So open up BalloonGameTutorialAppDelegate.m, and in the first line within the applicationDidFinishLaunching: method add:
Your applicationDidFinishLaunching: method should now look similar to this:
// Enable retina display support
Game *game = [[Game alloc] initWithWidth:320 height:480];
sparrowView.stage = game;
Now Build and Run the project, and you should be able to see the game running in retina display mode, I added the words High Definition to the images included with the project to illustrate that the new higher definition images are indeed displaying. You can also select Window->Scale->100% to make your simulator display 1:1 for the iPhone’s resolution which makes it excessively large, but allows you to easily see HD is indeed working.
If you cannot see the words high definition you may have the retina screen turned off in the simulator, which means that in the Mac OS X menu you need to make sure Hardware->Device->Phone (Retina) is selected.
That is all there is to it, it is a very painless process with the Sparrow Framework.
The first tutorial in this series can be found here:
iPhone Balloon Game Programming Tutorial
You might be wondering why I didn’t pack the images using texture packer like in the Sparrow Framework’s tutorial on hd support. My reason for that is simply because we’re still adding images to the project, and rather than pack the images over and over again we will do that when we add the finishing touches to the project.
In the next tutorial we will add menus to the game.
Apple has created some great tools to help you debug and optimize your iPhone and iPad apps.
However, knowing exactly what they do can be a challenge. I’m still figuring everything out and finding new uses for the tools. I suspect that unless you have been working on Mac software development for a long time then you probably feel the same. With the addition of multitasking this has gained even greater importance as apps now require further optimization.
I found this nice little rundown of all the latest tools available with Xcode.
The rundown can be found here:
Apple’s Instruments for Developers
If you’re new to Xcode, or you just don’t feel your getting the most out of Instruments in Xcode then I suggest checking it out.
If you like this, please share it!
This may hurt some fanboys, but many believe that Microsoft Visual Studio is a better IDE, and that Xcode just plain sucks. I think most of the hate towards Xcode stems from many of it’s features being turned off when first installed. I found these great tips today on how to make Xcode feel like Microsoft Visual Studio.
The article covers tips on changing the cut and paste buttons so Windows users feel more at home, implementing an MSVC key configuration in Xcode, installing a decent SVN client and more.
You can view the article here: How To Make Xcode Feel Like Visual Studio (MSVC)
If you’re really looking to create a power XCode setup, and unleash similar power to that of Visual Studio, I suggest checking out this article which covers many Xcode tips: Amazing Xcode Tips Leave Developer In A State Of Shock
Personally I don’t think Xcode will ever match one of the professional versions of Visual Studio, but you can’t really beat the price.. and I like it better than VC Express.. that’s for sure.
Xcode, the IDE provided by Apple for iPhone and Mac development is widely purported by beginning iPhone developers in online forums to be terrible. For awhile I believed the forum trolls, and I accepted that Xcode was a subpar IDE. In months of usage I didn’t think much of it only making a few preference changes enabling little more than code completion. Recently however, I came across a great set of tips that opened my eyes to the possibility that Xcode wasn’t as bad as these newbies (interestingly enough.. mainly Java developers) said.
A Great Set of Tips And Tricks
So a few days ago I came across a collection of Xcode tips. Now most of these tips I knew about, but a few of them I didn’t even after months of using Xcode. I hadn’t really explored all the shortcuts, or even clicked all those little buttons in the coding environment.
Link: 10 Xcode Tips And Tricks
Xcode Objective-C Macros Cheat Sheet
Since I didn’t know all those tips, I decided to look further, and while I was aware that macros had existed, I had never come across this excellent cheat sheet of the 34 most commonly used Objective-C Macros.
How To Make Custom Macros In Xcode
Now, I’ve seen some developers upset, and even say they’d rather use TextMate. For those guys I found this post on creating custom TextMate like Macros in Xcode
Xcode All-In-One Window Mode
This was a great feature that I already knew about, but if you’re not using this and you hate Xcode, well, chances are not knowing this could be why:
Using all-in-one mode could change your life, and I’m not kidding.
Xcode Shortcut List In One Printable Page
Eventually I found this massively cool Xcode shortcut list, and yes, seriously.. there are that many.
Link: Xcode Shortcut List
Ultimately, Xcode is a very competitive IDE. Sure, when you first start it up it won’t compare with that IDE you’ve customized to your exact likings over the years, but before you added those plugins, and changed all those settings wasn’t your old IDE bad too? Once you’ve got it all set up, and understand all the features that have been shown the article above you’ll be shocked at how productive you can be with Xcode.
Be sure to check back, I’m still perfecting things, but I feel an ultimate Xcode setup guide coming on.
Photo Credit: Freedigitalphotos.net