views:

10

answers:

0

Hi,

I used the solution here http://stackoverflow.com/questions/2863626/using-cgcontext-to-display-a-sprite-sheet-iphone to create an animated spritesheet class (A child of UIImageView) that takes in a huge (200+) frame spritesheet and animates it using a firing NSTimer.

I was wondering if anyone had any ideas how to control the resultant memory explosion?

Code is as follows:

-(void)animationIncrease:(NSTimer *)firingTimer
{
    self.currentFrame++;
    if (self.currentFrame >= self.totalFrameCount) {
        self.currentFrame = 0;
    }

    CGRect framedRect = CGRectMake(0, self.frameHeight * self.currentFrame, self.frameWidth, self.frameHeight);
    self.image = [UIImage imageWithCGImage:CGImageCreateWithImageInRect([self.spriteSheet CGImage] , framedRect)];
}