mpatric.com

Development

Posted Tue 01 Nov 2011 by Michael Patricios , 0 comments

Continuing with my extensions to Apple's Texture2D class, this post is about extending it to render a sprite from a sprite sheet, which is basically just rendering only part of the texture. Sprite sheets are useful for storing all of the frames for an animated sprite, or simply for storing multiple images in a single texture. It's not only convenient, but can have a positive effect on performance as the texture does not need to be changed from one sprite to the next (although I haven't made this optimisation in the example code, which selects the texture each time).

This simple implementation requires all the sprites to be the same size, laid out from left-to-right and top-to-bottom in the texture. For example, the following sprite sheet was created using some sprites from Prince of Persia:

A sprite sheet

Posted Fri 21 Oct 2011 by Michael Patricios , 1 comment

The Texture2D class was included with Apple's CrashLanding iOS sample application. Many developers pulled it out of this sample app to use in their own apps as a quick and easy way of rendering 2D images of any size and a variety of colour formats in OpenGL. I find it useful, particularly when prototyping ideas, however the class is limited in its functionality. I developed a small set of extensions for Texture2D for my own purposes and thought others might find them useful. This post describes how to extend Texture2D to allow you to rotate it about its center by an arbitrary angle. The Objective-C code is available on github.

Texture2D rotation screenshot

Posted Fri 17 Jun 2011 by Michael Patricios , 0 comments

The code that powers this blog is now available on github. Features include:

  • Admin interface, with support for (unpublished) draft posts and draft versions
  • Anti-spam protection on comments via Akismet
  • Assets stored on Amazon S3
  • Avatars on comments pulled from Gravatar
  • Apps built with this engine can easily be hosted on Heroku
  • Atom feeds for posts and comments
  • Highly customisable

Building a blog using the badass rails engine is straight-forward and quick. A guide is provided with the code.

Posted Sat 21 May 2011 by Michael Patricios , 9 comments

When using a Navigation Controller in a Cocoa Touch application, the framework takes care of many things, including generation of a back button when you push a view controller to the navigation controller. The back button gets the same title of the parent view, which a lot of the time is what you might want, but every now and again it's not. For example, in my cool application, the initial view has the title 'My Cool Application' - when you navigate to the settings view, the back button has the long, unwieldy title 'My Cool Application', making the button so big that it pushes the 'Settings' title to the right.

First level navigation view Second level navigation view

Posted Fri 15 May 2009 by Michael Patricios , 0 comments

On the iPhone it seems to have become commonplace to use a NSTimer to trigger redraws on OpenGL ES applications when displaying a changing or animated scene. To run smoothly, a frame rate of 30fps or higher is generally aimed for (60fps being the maximum, limited by the iPhone hardware refresh).

Relying on a timer to fire the code that renders the frame has its pros and its cons. The pros are simplicity and having everything in the same thread of execution (or runloop) means not having to worry about concurrency issues. The cons are what I'm more interested in..