Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // iBrideViewController.m
- // iBride
- //
- // Created by Alexander Morgun on 29.12.09.
- // Copyright __MyCompanyName__ 2009. All rights reserved.
- //
- #import "iBrideViewController.h"
- @implementation iBrideViewController
- int buttonOfGirlX [] = {44,203,44,195};
- int buttonOfGirlY [] = {11,6,247,246};
- int mainGirlX [] = {215,201,215,215,201};
- int mainGirlY [] = {20,127,202,307,386};
- int mainGirlW [] = {105,113,105,93,386};
- int mainGirlH [] = {99,67,97,75,77};
- int groomX [] = {20,88,180,50,152,248,20,110,227};
- int groomY [] = {7,12,12,165,157,138,320,307,299};
- // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self showBackground];
- }
- - (void)showBackground {
- //Рисуем заставку игры
- backgroundView = [[UIView alloc] initWithFrame: CGRectMake(0,0,320,480)];
- UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"ibridescover" ofType:@"png"]];
- backgroundImage = [[UIImageView alloc] initWithFrame: CGRectMake(0,0,320,480)];
- backgroundImage.image = tempImg;
- [backgroundView addSubview: backgroundImage];
- [self.view addSubview: backgroundView];
- [tempImg release];
- [backgroundImage release];
- [backgroundView release];
- }
- - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
- //Старт гейм
- if (backgroundVisible == NO) {
- backgroundVisible = YES;
- [backgroundImage removeFromSuperview];
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:1.2];
- [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
- [backgroundView removeFromSuperview];
- [UIView commitAnimations];
- [self chooseGirl];
- }
- }
- - (void)chooseGirl {
- //Рисуем объекты для выбора девушки
- chooseGirlView = [[UIView alloc] initWithFrame: CGRectMake(0,0,320,480)];
- UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"bride-choices" ofType:@"png"]];
- backgroundImage = [[UIImageView alloc] initWithFrame: CGRectMake(0,0,320,480)];
- backgroundImage.image = tempImg;
- [self.view addSubview: chooseGirlView];
- [chooseGirlView addSubview: backgroundImage];
- [tempImg release];
- [backgroundImage release];
- [chooseGirlView release];
- arrayOfButtons = [[NSMutableArray alloc] init];
- //Кнопки с номером девушки
- for (int i=0; i<4; i++) {
- UIButton *buttonOfGirl = [UIButton buttonWithType:UIButtonTypeCustom];
- [buttonOfGirl addTarget:self action:@selector(goToBigGirl:) forControlEvents:UIControlEventTouchUpInside];
- [buttonOfGirl setFrame: CGRectMake(buttonOfGirlX[i], buttonOfGirlY[i], 88, 225)];
- buttonOfGirl.tag = i;
- [arrayOfButtons addObject: buttonOfGirl];
- [self.view addSubview: buttonOfGirl];
- }
- }
- - (void)goToBigGirl: (UIButton *) but {
- //Переход на выбранную девушку
- numberOfGirl = but.tag;
- for (int i=0; i<4; i++) {
- UIButton *tempButton = [arrayOfButtons objectAtIndex: i];
- [tempButton removeFromSuperview];
- }
- [backgroundImage removeFromSuperview];
- [arrayOfButtons removeAllObjects];
- [arrayOfButtons release];
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:1.2];
- [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
- [chooseGirlView removeFromSuperview];
- [UIView commitAnimations];
- //Отображаем выбранную девушку
- mainGirl = [[UIView alloc] initWithFrame: CGRectMake(0,0,320,480)];
- UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource: [NSString stringWithFormat: @"biggirl%d", (numberOfGirl+1)] ofType:@"png"]];
- backgroundImage = [[UIImageView alloc] initWithFrame: CGRectMake(0,0,320,480)];
- backgroundImage.image = tempImg;
- [self.view addSubview: mainGirl];
- [mainGirl addSubview: backgroundImage];
- [tempImg release];
- [backgroundImage release];
- [mainGirl release];
- UIImage *tempImg2 = [[UIImage alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @"back-button" ofType:@"png"]];
- buttForBackToChooseGirl = [UIButton buttonWithType:UIButtonTypeCustom];
- [buttForBackToChooseGirl setImage:tempImg2 forState:UIControlStateNormal];
- [buttForBackToChooseGirl addTarget:self action:@selector(backToChooseGirl) forControlEvents:UIControlEventTouchUpInside];
- [buttForBackToChooseGirl setFrame: CGRectMake(2, 450, 55, 28)];
- [self.view addSubview: buttForBackToChooseGirl];
- [tempImg2 release];
- arrayOfButtonsMainGirl = [[NSMutableArray alloc] init];
- for (int i=0; i<5; i++) {
- UIButton *buttonOfGirl = [UIButton buttonWithType:UIButtonTypeCustom];
- [buttonOfGirl addTarget:self action:@selector(whatDoNow:) forControlEvents:UIControlEventTouchUpInside];
- [buttonOfGirl setFrame: CGRectMake(mainGirlX[i], mainGirlY[i], mainGirlW[i], mainGirlH[i])];
- buttonOfGirl.tag = i;
- [arrayOfButtonsMainGirl addObject: buttonOfGirl];
- [self.view addSubview: buttonOfGirl];
- }
- }
- - (void)whatDoNow: (UIButton *) but {
- //Переход на выбранную девушку
- [self cleanMainGirl];
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:1.2];
- [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
- [mainGirl removeFromSuperview];
- [UIView commitAnimations];
- switch (but.tag) {
- case 0:
- [self chooseGroom];
- break;
- case 1:
- [self chooseRings];
- break;
- case 2:
- [self chooseBride];
- break;
- case 3:
- [self chooseCake];
- break;
- case 4:
- [self chooseChapel];
- break;
- }
- }
- - (void) cleanMainGirl {
- for (int i=0; i<5; i++) {
- UIButton *tempButton = [arrayOfButtonsMainGirl objectAtIndex: i];
- [tempButton removeFromSuperview];
- }
- [arrayOfButtonsMainGirl removeAllObjects];
- [arrayOfButtonsMainGirl release];
- [backgroundImage removeFromSuperview];
- [buttForBackToChooseGirl removeFromSuperview];
- }
- - (void)backToChooseGirl {
- [self cleanMainGirl];
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:1.2];
- [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
- [mainGirl removeFromSuperview];
- [UIView commitAnimations];
- [self chooseGirl];
- }
- - (void) chooseGroom {
- manyGrooms = [[UIView alloc] initWithFrame: CGRectMake(0,0,320,480)];
- UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"husband-page" ofType:@"png"]];
- backgroundImage = [[UIImageView alloc] initWithFrame: CGRectMake(0,0,320,480)];
- backgroundImage.image = tempImg;
- [self.view addSubview: manyGrooms];
- [manyGrooms addSubview: backgroundImage];
- [tempImg release];
- [backgroundImage release];
- [manyGrooms release];
- arrayOfMiniGroom = [NSMutableArray alloc];
- for (int i=0; i<8; i++) {
- UIButton *buttonOfGroom = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- [buttonOfGroom addTarget:self action:@selector(whatDoNow:) forControlEvents:UIControlEventTouchUpInside];
- [buttonOfGroom setFrame: CGRectMake(groomX[i], groomY[i], 50, 145)];
- buttonOfGroom.tag = i;
- [arrayOfMiniGroom addObject: buttonOfGroom];
- [self.view addSubview: buttonOfGroom];
- }
- }
- - (void)didReceiveMemoryWarning {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
- // Release any cached data, images, etc that aren't in use.
- }
- - (void)viewDidUnload {
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
- }
- - (void)dealloc {
- [super dealloc];
- }
- @end
Add Comment
Please, Sign In to add comment