change is such hard work

In this version I removed lots of repeated calls to self.layer.contents=... in the animation code, by modifying and checking a frame number instead. When the number changes, the code sets the layer contents to the next image. Eventually I’ll move this code into an Animation class, which will be used by both the sprites and the tiled view.

This small change made a massive improvement, increasing the frame rate on the iPod 4th generation device and iPad 1st generation from about 30 to 40 frames per second (FPS) up to 60 FPS during scrolling, and 60 FPS when not scrolling. By reducing the amount of work the GPU is having to perform, we get the double benefit of increased frame rate and reduced battery use.