Posted Tue 22 Nov 2011 by Michael Patricios , 1 comment

Continuing with my extensions to Apple's Texture2D class, this post is about extending the sprite sheet functionality in part 2 to render sprites of arbitrary size indexed by an atlas. This is more flexible than having all sprites of the same dimension, laid out uniformly in a large texture image. You can even have overlapping sprites and do other funky things as you're in full control over exactly which part of the texture to render.

For example, the following texture atlas is an extension of the sprite sheet used in part 2 and contains sprites of different sizes laid out in no particular way in the image:

Texture atlas

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