project_files/HedgewarsMobile/Classes/HogButtonView.m
changeset 3697 d5b30d6373fc
parent 3547 02875b1145b7
child 3783 8e9daf967406
equal deleted inserted replaced
3695:c11abf387a7d 3697:d5b30d6373fc
    14 @synthesize singleHog, numberOfHogs, ownerDictionary;
    14 @synthesize singleHog, numberOfHogs, ownerDictionary;
    15 
    15 
    16 -(id) initWithFrame:(CGRect)frame {
    16 -(id) initWithFrame:(CGRect)frame {
    17     if ((self = [super initWithFrame:frame])) {
    17     if ((self = [super initWithFrame:frame])) {
    18         self.backgroundColor = [UIColor clearColor];
    18         self.backgroundColor = [UIColor clearColor];
    19         
    19 
    20         NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/Hedgehog.png",GRAPHICS_DIRECTORY()];
    20         NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/Hedgehog.png",GRAPHICS_DIRECTORY()];
    21         UIImage *normalHogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile andCutAt:CGRectMake(96, 0, 32, 32)];
    21         UIImage *normalHogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile andCutAt:CGRectMake(96, 0, 32, 32)];
    22         [normalHogFile release];
    22         [normalHogFile release];
    23         
    23 
    24         self.singleHog = normalHogSprite;
    24         self.singleHog = normalHogSprite;
    25         [normalHogSprite release];
    25         [normalHogSprite release];
    26         [self addTarget:self action:@selector(addOne) forControlEvents:UIControlEventTouchUpInside];
    26         [self addTarget:self action:@selector(addOne) forControlEvents:UIControlEventTouchUpInside];
    27     }
    27     }
    28     return self;
    28     return self;
    44                 numberOfHogs = 1;
    44                 numberOfHogs = 1;
    45             else
    45             else
    46                 numberOfHogs = MAX_HOGS;
    46                 numberOfHogs = MAX_HOGS;
    47         }
    47         }
    48         [ownerDictionary setObject:[NSNumber numberWithInt:numberOfHogs] forKey:@"number"];
    48         [ownerDictionary setObject:[NSNumber numberWithInt:numberOfHogs] forKey:@"number"];
    49         
    49 
    50         UIImage *teamHogs = [[[UIImage alloc] init] autorelease];
    50         UIImage *teamHogs = [[[UIImage alloc] init] autorelease];
    51         for (int i = 0; i < numberOfHogs; i++) {
    51         for (int i = 0; i < numberOfHogs; i++) {
    52             teamHogs = [singleHog mergeWith:teamHogs
    52             teamHogs = [singleHog mergeWith:teamHogs
    53                                     atPoint:CGPointMake(8, 0) 
    53                                     atPoint:CGPointMake(8, 0)
    54                                      atSize:CGSizeMake(88, 32)];
    54                                      atSize:CGSizeMake(88, 32)];
    55         }
    55         }
    56         [self setImage:teamHogs forState:UIControlStateNormal];
    56         [self setImage:teamHogs forState:UIControlStateNormal];
    57     }
    57     }
    58 }
    58 }