cocoaTouch/HogHatViewController.m
changeset 3357 3836a31879e7
parent 3352 ac5d14a35482
child 3374 0d522416d97f
equal deleted inserted replaced
3356:3ae3fccb439e 3357:3836a31879e7
    27     // load all the hat file names and store them into hatArray
    27     // load all the hat file names and store them into hatArray
    28     NSString *hatsDirectory = HATS_DIRECTORY();
    28     NSString *hatsDirectory = HATS_DIRECTORY();
    29     NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:hatsDirectory error:NULL];
    29     NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:hatsDirectory error:NULL];
    30     self.hatArray = array;
    30     self.hatArray = array;
    31     
    31     
       
    32     NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/Hedgehog.png",GRAPHICS_DIRECTORY()];
       
    33     UIImage *normalHogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile andCutAt:CGRectMake(96, 0, 32, 32)];
       
    34     [normalHogFile release];
       
    35     
    32     // load all the hat images from the previous array but save only the first sprite and store it in hatSprites
    36     // load all the hat images from the previous array but save only the first sprite and store it in hatSprites
    33     NSMutableArray *spriteArray = [[NSMutableArray alloc] initWithCapacity:[hatArray count]];
    37     NSMutableArray *spriteArray = [[NSMutableArray alloc] initWithCapacity:[hatArray count]];
    34     for (NSString *hat in hatArray) {
    38     for (NSString *hat in hatArray) {
    35         NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@", hatsDirectory,hat];
    39         NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@", hatsDirectory,hat];
    36         UIImage *hatSprite = [[UIImage alloc] initWithContentsOfFile: hatFile andCutAt:CGRectMake(0, 0, 32, 32)];
    40         UIImage *hatSprite = [[UIImage alloc] initWithContentsOfFile: hatFile andCutAt:CGRectMake(0, 0, 32, 32)];
    37         [hatFile release];
    41         [hatFile release];
    38         [spriteArray addObject:hatSprite];
    42         [spriteArray addObject:[normalHogSprite mergeWith:hatSprite atPoint:CGPointMake(0, -5)]];
    39         [hatSprite release];
    43         [hatSprite release];
    40     }
    44     }
       
    45     [normalHogSprite release];
    41     self.hatSprites = spriteArray;
    46     self.hatSprites = spriteArray;
    42     [spriteArray release];
    47     [spriteArray release];
    43 }
    48 }
    44 
    49 
    45 - (void)viewWillAppear:(BOOL)animated {
    50 - (void)viewWillAppear:(BOOL)animated {