Advertisement
Guest User

Animation sa doors

a guest
Jul 28th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void) goToNextRoomThroughDoor {
  2.     UIButton * doorButton = self.lastDoorTapped;
  3.     float scale = 6.5;
  4.    
  5.     // store center point of the door to be animated
  6.     self.lastDoorCenterPoint = CGPointMake(doorButton.center.x, doorButton.center.y);
  7.    
  8.     // translation points
  9.     int door1x = -1000;
  10.     int door1y = -2500;
  11.     int door2x = -2850;
  12.     int door2y = -2500;
  13.     int door3x = -4700;
  14.     int door3y = -2500;
  15.    
  16.     // move door
  17.     [UIView animateWithDuration:0.3 animations:^{
  18.         if (self.buttonDoor1 == doorButton) {
  19.             doorButton.transform = CGAffineTransformMakeTranslation(-doorButton.frame.size.width, 0);
  20.         } else if (self.buttonDoor2 == doorButton) {
  21.             doorButton.transform = CGAffineTransformMakeTranslation(0, -doorButton.frame.size.height);
  22.         } else {
  23.             doorButton.transform = CGAffineTransformMakeTranslation(doorButton.frame.size.width, 0);
  24.         }
  25.     } completion:^(BOOL finished) {
  26.         // zoom
  27.         [UIView animateWithDuration:0.5 animations:^{
  28.             float width = self.view.frame.size.width;
  29.             float height = self.view.frame.size.height;
  30.            
  31.             // transform
  32.             self.view.transform = CGAffineTransformScale(CGAffineTransformIdentity, scale, scale);
  33.            
  34.             // zoom to specific area
  35.             if (self.buttonDoor1 == doorButton) {
  36.                 self.view.frame = CGRectMake(door1x, door1y, width * scale, height * scale);
  37.             } else if (self.buttonDoor2 == doorButton) {
  38.                 self.view.frame = CGRectMake(door2x, door2y, width * scale, height * scale);
  39.             } else {
  40.                 self.view.frame = CGRectMake(door3x, door3y, width * scale, height * scale);
  41.             }
  42.         } completion:^(BOOL finished) {
  43.             [self goToNextRoom];
  44.         }];
  45.     }];
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement