1.1 --- a/Source/CheckersGame.m Thu Jul 03 17:44:30 2008 -0700
1.2 +++ b/Source/CheckersGame.m Sat Jul 05 17:46:43 2008 -0700
1.3 @@ -30,6 +30,25 @@
1.4 @implementation CheckersGame
1.5
1.6
1.7 +static NSMutableDictionary *kPieceStyle1, *kPieceStyle2;
1.8 +
1.9 ++ (void) initialize
1.10 +{
1.11 + if( self == [CheckersGame class] ) {
1.12 + kPieceStyle1 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
1.13 + (id)GetCGImageNamed(@"Green.png"), @"contents",
1.14 + kCAGravityResizeAspect, @"contentsGravity",
1.15 + kCAFilterLinear, @"minificationFilter",
1.16 + nil];
1.17 + kPieceStyle2 = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
1.18 + (id)GetCGImageNamed(@"Red.png"), @"contents",
1.19 + kCAGravityResizeAspect, @"contentsGravity",
1.20 + kCAFilterLinear, @"minificationFilter",
1.21 + nil];
1.22 + }
1.23 +}
1.24 +
1.25 +
1.26 - (id) init
1.27 {
1.28 self = [super init];
1.29 @@ -52,8 +71,9 @@
1.30
1.31 - (Piece*) pieceForPlayer: (int)playerNum
1.32 {
1.33 - Piece *p = [[Piece alloc] initWithImageNamed: (playerNum==0 ?@"Green.png" :@"Red.png")
1.34 - scale: floor(_grid.spacing.width * 1.0)];
1.35 + Piece *p = [[Piece alloc] init];
1.36 + p.bounds = CGRectMake(0,0,floor(_grid.spacing.width),floor(_grid.spacing.height));
1.37 + p.style = (playerNum ?kPieceStyle2 :kPieceStyle1);
1.38 p.owner = [self.players objectAtIndex: playerNum];
1.39 p.name = playerNum ?@"2" :@"1";
1.40 return [p autorelease];
1.41 @@ -68,7 +88,7 @@
1.42
1.43 - (void) setUpBoard
1.44 {
1.45 - RectGrid *grid = [[[RectGrid alloc] initWithRows: 8 columns: 8 frame: _board.bounds] autorelease];
1.46 + RectGrid *grid = [[RectGrid alloc] initWithRows: 8 columns: 8 frame: _board.bounds];
1.47 _grid = grid;
1.48 [_board addSublayer: _grid];
1.49 CGPoint pos = _grid.position;