Guest User

Untitled

a guest
Jul 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.64 KB | None | 0 0
  1. //
  2. // iBrideViewController.m
  3. // iBride
  4. //
  5. // Created by Alexander Morgun on 29.12.09.
  6. // Copyright __MyCompanyName__ 2009. All rights reserved.
  7. //
  8.  
  9. #import "iBrideViewController.h"
  10.  
  11. @implementation iBrideViewController
  12.  
  13. int buttonOfGirlX [] = {44,203,44,195};
  14. int buttonOfGirlY [] = {11,6,247,246};
  15.  
  16. int mainGirlX [] = {215,201,215,215,201};
  17. int mainGirlY [] = {20,127,202,307,386};
  18. int mainGirlW [] = {105,113,105,93,386};
  19. int mainGirlH [] = {99,67,97,75,77};
  20.  
  21. int groomX [] = {20,88,180,50,152,248,20,110,227};
  22. int groomY [] = {7,12,12,165,157,138,320,307,299};
  23.  
  24. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. [self showBackground];
  28. }
  29.  
  30. - (void)showBackground {
  31. //Рисуем заставку игры
  32. backgroundView = [[UIView alloc] initWithFrame: CGRectMake(0,0,320,480)];
  33. UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"ibridescover" ofType:@"png"]];
  34. backgroundImage = [[UIImageView alloc] initWithFrame: CGRectMake(0,0,320,480)];
  35. backgroundImage.image = tempImg;
  36. [backgroundView addSubview: backgroundImage];
  37. [self.view addSubview: backgroundView];
  38. [tempImg release];
  39. [backgroundImage release];
  40. [backgroundView release];
  41. }
  42.  
  43. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
  44. //Старт гейм
  45. if (backgroundVisible == NO) {
  46. backgroundVisible = YES;
  47.  
  48. [backgroundImage removeFromSuperview];
  49.  
  50. [UIView beginAnimations:nil context:NULL];
  51. [UIView setAnimationDuration:1.2];
  52. [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
  53. [backgroundView removeFromSuperview];
  54. [UIView commitAnimations];
  55.  
  56. [self chooseGirl];
  57. }
  58. }
  59.  
  60. - (void)chooseGirl {
  61. //Рисуем объекты для выбора девушки
  62. chooseGirlView = [[UIView alloc] initWithFrame: CGRectMake(0,0,320,480)];
  63. UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"bride-choices" ofType:@"png"]];
  64. backgroundImage = [[UIImageView alloc] initWithFrame: CGRectMake(0,0,320,480)];
  65. backgroundImage.image = tempImg;
  66. [self.view addSubview: chooseGirlView];
  67. [chooseGirlView addSubview: backgroundImage];
  68.  
  69. [tempImg release];
  70. [backgroundImage release];
  71. [chooseGirlView release];
  72.  
  73. arrayOfButtons = [[NSMutableArray alloc] init];
  74. //Кнопки с номером девушки
  75. for (int i=0; i<4; i++) {
  76. UIButton *buttonOfGirl = [UIButton buttonWithType:UIButtonTypeCustom];
  77. [buttonOfGirl addTarget:self action:@selector(goToBigGirl:) forControlEvents:UIControlEventTouchUpInside];
  78. [buttonOfGirl setFrame: CGRectMake(buttonOfGirlX[i], buttonOfGirlY[i], 88, 225)];
  79. buttonOfGirl.tag = i;
  80. [arrayOfButtons addObject: buttonOfGirl];
  81. [self.view addSubview: buttonOfGirl];
  82. }
  83. }
  84.  
  85.  
  86. - (void)goToBigGirl: (UIButton *) but {
  87. //Переход на выбранную девушку
  88. numberOfGirl = but.tag;
  89. for (int i=0; i<4; i++) {
  90. UIButton *tempButton = [arrayOfButtons objectAtIndex: i];
  91. [tempButton removeFromSuperview];
  92. }
  93. [backgroundImage removeFromSuperview];
  94. [arrayOfButtons removeAllObjects];
  95. [arrayOfButtons release];
  96.  
  97. [UIView beginAnimations:nil context:NULL];
  98. [UIView setAnimationDuration:1.2];
  99. [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
  100. [chooseGirlView removeFromSuperview];
  101. [UIView commitAnimations];
  102.  
  103.  
  104. //Отображаем выбранную девушку
  105. mainGirl = [[UIView alloc] initWithFrame: CGRectMake(0,0,320,480)];
  106. UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource: [NSString stringWithFormat: @"biggirl%d", (numberOfGirl+1)] ofType:@"png"]];
  107. backgroundImage = [[UIImageView alloc] initWithFrame: CGRectMake(0,0,320,480)];
  108. backgroundImage.image = tempImg;
  109. [self.view addSubview: mainGirl];
  110. [mainGirl addSubview: backgroundImage];
  111.  
  112. [tempImg release];
  113. [backgroundImage release];
  114. [mainGirl release];
  115.  
  116. UIImage *tempImg2 = [[UIImage alloc] initWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @"back-button" ofType:@"png"]];
  117. buttForBackToChooseGirl = [UIButton buttonWithType:UIButtonTypeCustom];
  118. [buttForBackToChooseGirl setImage:tempImg2 forState:UIControlStateNormal];
  119. [buttForBackToChooseGirl addTarget:self action:@selector(backToChooseGirl) forControlEvents:UIControlEventTouchUpInside];
  120. [buttForBackToChooseGirl setFrame: CGRectMake(2, 450, 55, 28)];
  121. [self.view addSubview: buttForBackToChooseGirl];
  122. [tempImg2 release];
  123.  
  124. arrayOfButtonsMainGirl = [[NSMutableArray alloc] init];
  125. for (int i=0; i<5; i++) {
  126. UIButton *buttonOfGirl = [UIButton buttonWithType:UIButtonTypeCustom];
  127. [buttonOfGirl addTarget:self action:@selector(whatDoNow:) forControlEvents:UIControlEventTouchUpInside];
  128. [buttonOfGirl setFrame: CGRectMake(mainGirlX[i], mainGirlY[i], mainGirlW[i], mainGirlH[i])];
  129. buttonOfGirl.tag = i;
  130. [arrayOfButtonsMainGirl addObject: buttonOfGirl];
  131. [self.view addSubview: buttonOfGirl];
  132. }
  133. }
  134. - (void)whatDoNow: (UIButton *) but {
  135. //Переход на выбранную девушку
  136. [self cleanMainGirl];
  137.  
  138. [UIView beginAnimations:nil context:NULL];
  139. [UIView setAnimationDuration:1.2];
  140. [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
  141. [mainGirl removeFromSuperview];
  142. [UIView commitAnimations];
  143.  
  144. switch (but.tag) {
  145. case 0:
  146. [self chooseGroom];
  147. break;
  148.  
  149. case 1:
  150. [self chooseRings];
  151. break;
  152.  
  153. case 2:
  154. [self chooseBride];
  155. break;
  156.  
  157. case 3:
  158. [self chooseCake];
  159. break;
  160.  
  161. case 4:
  162. [self chooseChapel];
  163. break;
  164. }
  165. }
  166.  
  167. - (void) cleanMainGirl {
  168. for (int i=0; i<5; i++) {
  169. UIButton *tempButton = [arrayOfButtonsMainGirl objectAtIndex: i];
  170. [tempButton removeFromSuperview];
  171. }
  172. [arrayOfButtonsMainGirl removeAllObjects];
  173. [arrayOfButtonsMainGirl release];
  174.  
  175. [backgroundImage removeFromSuperview];
  176. [buttForBackToChooseGirl removeFromSuperview];
  177. }
  178.  
  179. - (void)backToChooseGirl {
  180. [self cleanMainGirl];
  181.  
  182. [UIView beginAnimations:nil context:NULL];
  183. [UIView setAnimationDuration:1.2];
  184. [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
  185. [mainGirl removeFromSuperview];
  186. [UIView commitAnimations];
  187.  
  188. [self chooseGirl];
  189. }
  190.  
  191.  
  192.  
  193. - (void) chooseGroom {
  194. manyGrooms = [[UIView alloc] initWithFrame: CGRectMake(0,0,320,480)];
  195. UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"husband-page" ofType:@"png"]];
  196. backgroundImage = [[UIImageView alloc] initWithFrame: CGRectMake(0,0,320,480)];
  197. backgroundImage.image = tempImg;
  198. [self.view addSubview: manyGrooms];
  199. [manyGrooms addSubview: backgroundImage];
  200.  
  201. [tempImg release];
  202. [backgroundImage release];
  203. [manyGrooms release];
  204.  
  205. arrayOfMiniGroom = [NSMutableArray alloc];
  206.  
  207. for (int i=0; i<8; i++) {
  208. UIButton *buttonOfGroom = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  209. [buttonOfGroom addTarget:self action:@selector(whatDoNow:) forControlEvents:UIControlEventTouchUpInside];
  210. [buttonOfGroom setFrame: CGRectMake(groomX[i], groomY[i], 50, 145)];
  211. buttonOfGroom.tag = i;
  212. [arrayOfMiniGroom addObject: buttonOfGroom];
  213. [self.view addSubview: buttonOfGroom];
  214. }
  215. }
  216.  
  217.  
  218. - (void)didReceiveMemoryWarning {
  219. // Releases the view if it doesn't have a superview.
  220. [super didReceiveMemoryWarning];
  221.  
  222. // Release any cached data, images, etc that aren't in use.
  223. }
  224.  
  225. - (void)viewDidUnload {
  226. // Release any retained subviews of the main view.
  227. // e.g. self.myOutlet = nil;
  228. }
  229.  
  230.  
  231. - (void)dealloc {
  232. [super dealloc];
  233. }
  234.  
  235. @end
Add Comment
Please, Sign In to add comment