Updated Thu 28 Nov 2013 by Michael Patricios , 10 comments

A while ago I needed to allow users to enter a monetary value into a text input in an iOS app. There seem to be a few approaches to doing this, such as:

  • Use a text field with a full keyboard and validate what the user entered, or only accept numeric input and a period or comma character
  • Use a text field with a numeric keypad, but don't allow minor units (cents/pence) as there is no period or comma character available on this keypad
  • Use spinners

To me, none of these options gives a good user experience; I find the best approach is what many ATMs do, which is to allow you to enter only the digits, but have a fixed decimal separator. So, to enter '123.45' you would type 1-2-3-4-5; to enter '18.00' you would type 1-8-0-0; and so on.

In this post, I am going to do this in iOS with a text input and a numeric keypad. The Objective-C code for this is available on github.

Decimal text input

Posted Sat 02 Nov 2013 by Michael Patricios , 0 comments

If, like me, you have iOS projects that use custom table cells in table views, you may have noticed that when rebuilding the projects for iOS7, table cells are always rendered with a white background, which means if your custom table cells have their own background you may not see it. The solution to this problem can be found in the UITableViewCell Class Reference:

Updated Sun 02 Sep 2012 by Michael Patricios , 0 comments

I recently built a simple retro snake game in javascript, with the game rendered on an HTML canvas and hi-scores in HTML local storage. You can play it online, or grab the source from github.

Canvas snake screenshot

Update: I've written a CoffeeScript version too, the source is on github.

Posted Tue 10 Jan 2012 by Michael Patricios , 0 comments

I've started using TexturePacker from Code'n'Web. There are versions for several platforms (including Mac OS X) and it can be easily integrated into your XCode build toolchain. It can also create standard definition textures and atlases from the high definition (i.e. retina-display) texture, and much more.. It has saved me a lot of time - if you're building a game with lots of sprite atlases, take a look at this tool. Well worth the US$24.95 asking price for the full version.


Posted Tue 22 Nov 2011 by Michael Patricios , 0 comments

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

Older postsPage 1 of 3