* Fixed scaling of king pieces when the board's state is set.
authorJens Alfke <jens@mooseyard.com>
Thu Jul 31 13:23:44 2008 -0700 (2008-07-31)
changeset 23efe5d4523a23
parent 22 4cb50131788f
child 24 db8640a38faf
* Fixed scaling of king pieces when the board's state is set.
* Added IBOutlets for tilting the BoardView.
Source/BoardView.h
Source/BoardView.m
Source/CheckersGame.m
     1.1 --- a/Source/BoardView.h	Thu Jul 31 11:18:13 2008 -0700
     1.2 +++ b/Source/BoardView.h	Thu Jul 31 13:23:44 2008 -0700
     1.3 @@ -61,6 +61,8 @@
     1.4  
     1.5  @property CGFloat perspective;
     1.6  
     1.7 +- (IBAction) tiltUp: (id)sender;
     1.8 +- (IBAction) tiltDown: (id)sender;
     1.9  - (IBAction) enterFullScreen: (id)sender;
    1.10  
    1.11  @property CGSize gameBoardInset;
     2.1 --- a/Source/BoardView.m	Thu Jul 31 11:18:13 2008 -0700
     2.2 +++ b/Source/BoardView.m	Thu Jul 31 13:23:44 2008 -0700
     2.3 @@ -51,6 +51,10 @@
     2.4  }
     2.5  
     2.6  
     2.7 +#pragma mark -
     2.8 +#pragma mark PERSPECTIVE:
     2.9 +
    2.10 +
    2.11  - (void) _applyPerspective
    2.12  {
    2.13      CATransform3D t;
    2.14 @@ -60,7 +64,7 @@
    2.15          t = CATransform3DConcat(t, CATransform3DMakeRotation(-_perspective, 1,0,0));
    2.16          
    2.17          CATransform3D pers = CATransform3DIdentity;
    2.18 -        pers.m34 = 1.0/-800;
    2.19 +        pers.m34 = 1.0/-2000;
    2.20          t = CATransform3DConcat(t, pers);
    2.21          t = CATransform3DConcat(t, CATransform3DMakeTranslation(size.width/2, 
    2.22                                                                  size.height*(0.25 + 0.05*sin(2*_perspective)),
    2.23 @@ -85,6 +89,13 @@
    2.24      }
    2.25  }
    2.26  
    2.27 +- (IBAction) tiltUp: (id)sender     {self.perspective -= M_PI/40;}
    2.28 +- (IBAction) tiltDown: (id)sender   {self.perspective += M_PI/40;}
    2.29 +
    2.30 +
    2.31 +#pragma mark -
    2.32 +#pragma mark GAME BOARD:
    2.33 +
    2.34  
    2.35  - (void) _removeGameBoard
    2.36  {
    2.37 @@ -134,6 +145,10 @@
    2.38  }
    2.39  
    2.40  
    2.41 +#pragma mark -
    2.42 +#pragma mark VIEW MANIPULATION:
    2.43 +
    2.44 +
    2.45  - (CGRect) gameBoardFrame
    2.46  {
    2.47      return CGRectInset(self.layer.bounds, _gameBoardInset.width,_gameBoardInset.height);
     3.1 --- a/Source/CheckersGame.m	Thu Jul 31 11:18:13 2008 -0700
     3.2 +++ b/Source/CheckersGame.m	Thu Jul 31 13:23:44 2008 -0700
     3.3 @@ -95,9 +95,9 @@
     3.4  
     3.5  - (void) makeKing: (Piece*)piece
     3.6  {
     3.7 -    piece.scale = kKingScale;
     3.8      piece.tag = YES;        // tag property stores the 'king' flag
     3.9      piece.name = piece.owner.index ?@"4" :@"3";
    3.10 +    [self _transformPiece: piece];
    3.11  }
    3.12  
    3.13  - (void) setUpBoard