Under the Bridge

Irregular Touch Detection

Here’s a clever strategy for fiddly touch detection requirements — use colors laid out in Photoshop to define your hotspots’ pixels:

Irregular touch detection, when CGRect is not enough – part 1

… This first approach involves building a map of the hit areas in Photoshop, saving as a Raw file and then using this data as a lookup (tools such as Gimp can also be used if they can save in this format).

A nice side effect of this approach is it moves the creation of the hit areas over to the creators of the content, the hotspot maps are stored within the Photoshop PSD files. If the image or the hit areas need changing just load in a new image and data file…

That’s actually a remarkably apropos strategy for a particular set of requirements we’re looking at here, better plan than any we’d come up with on our own. Sample snippets are for cocos2d, but the strategy is good for anything that needs mapping from a point to a set of irregular content!

h/t: @rwenderlich!

1