Finally fixed the slow animation performance of board games; all it took was changing the board's z index from 1 to 0, somehow. Games working well now.
1.1 --- a/GeekGameBoard-iPhone.xcodeproj/project.pbxproj Wed May 28 12:47:10 2008 -0700
1.2 +++ b/GeekGameBoard-iPhone.xcodeproj/project.pbxproj Thu May 29 15:04:06 2008 -0700
1.3 @@ -11,6 +11,8 @@
1.4 1D60589B0D05DD56006BFB54 /* main-iPhone.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main-iPhone.m */; };
1.5 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
1.6 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
1.7 + 2740502B0DEF36DF0006A9EE /* Pop.aiff in Resources */ = {isa = PBXBuildFile; fileRef = 274050290DEF36DF0006A9EE /* Pop.aiff */; };
1.8 + 2740502C0DEF36DF0006A9EE /* Tink.aiff in Resources */ = {isa = PBXBuildFile; fileRef = 2740502A0DEF36DF0006A9EE /* Tink.aiff */; };
1.9 279F4B590D85C51700B32DBF /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 279F4B580D85C51700B32DBF /* AudioToolbox.framework */; };
1.10 279F4B5B0D85C51700B32DBF /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 279F4B5A0D85C51700B32DBF /* QuartzCore.framework */; };
1.11 279F4B620D85C63000B32DBF /* GGBTextLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 279F4B610D85C63000B32DBF /* GGBTextLayer.m */; };
1.12 @@ -45,13 +47,20 @@
1.13 27C99B210D820868005AFD4F /* QuartzUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C99B0B0D820868005AFD4F /* QuartzUtils.m */; };
1.14 27C99B220D820868005AFD4F /* GGBUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C99B0D0D820868005AFD4F /* GGBUtils.m */; };
1.15 27C99B510D82106E005AFD4F /* GGBLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 27C99B500D82106E005AFD4F /* GGBLayer.m */; };
1.16 + 27DBB52C0DEE059700616D85 /* Blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 27DBB5270DEE059700616D85 /* Blue.png */; };
1.17 + 27DBB52D0DEE059800616D85 /* Gold.png in Resources */ = {isa = PBXBuildFile; fileRef = 27DBB5280DEE059700616D85 /* Gold.png */; };
1.18 + 27DBB52E0DEE059800616D85 /* Green.png in Resources */ = {isa = PBXBuildFile; fileRef = 27DBB5290DEE059700616D85 /* Green.png */; };
1.19 + 27DBB52F0DEE059900616D85 /* Red.png in Resources */ = {isa = PBXBuildFile; fileRef = 27DBB52A0DEE059700616D85 /* Red.png */; };
1.20 + 27DBB5300DEE059900616D85 /* Violet.png in Resources */ = {isa = PBXBuildFile; fileRef = 27DBB52B0DEE059700616D85 /* Violet.png */; };
1.21 /* End PBXBuildFile section */
1.22
1.23 /* Begin PBXFileReference section */
1.24 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1.25 1D3623EB0D0F72F000981E51 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
1.26 - 1D6058910D05DD3D006BFB54 /* GGB-iPhone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "GGB-iPhone.app"; sourceTree = BUILT_PRODUCTS_DIR; };
1.27 + 1D6058910D05DD3D006BFB54 /* GeekGameBoard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = GeekGameBoard.app; sourceTree = BUILT_PRODUCTS_DIR; };
1.28 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
1.29 + 274050290DEF36DF0006A9EE /* Pop.aiff */ = {isa = PBXFileReference; lastKnownFileType = audio.aiff; name = Pop.aiff; path = /System/Library/Sounds/Pop.aiff; sourceTree = "<absolute>"; };
1.30 + 2740502A0DEF36DF0006A9EE /* Tink.aiff */ = {isa = PBXFileReference; lastKnownFileType = audio.aiff; name = Tink.aiff; path = /System/Library/Sounds/Tink.aiff; sourceTree = "<absolute>"; };
1.31 279F4B580D85C51700B32DBF /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
1.32 279F4B5A0D85C51700B32DBF /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
1.33 279F4B600D85C63000B32DBF /* GGBTextLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GGBTextLayer.h; sourceTree = "<group>"; };
1.34 @@ -109,6 +118,11 @@
1.35 27C99B0D0D820868005AFD4F /* GGBUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GGBUtils.m; sourceTree = "<group>"; };
1.36 27C99B4F0D82106E005AFD4F /* GGBLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GGBLayer.h; sourceTree = "<group>"; };
1.37 27C99B500D82106E005AFD4F /* GGBLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GGBLayer.m; sourceTree = "<group>"; };
1.38 + 27DBB5270DEE059700616D85 /* Blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Blue.png; sourceTree = "<group>"; };
1.39 + 27DBB5280DEE059700616D85 /* Gold.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Gold.png; sourceTree = "<group>"; };
1.40 + 27DBB5290DEE059700616D85 /* Green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Green.png; sourceTree = "<group>"; };
1.41 + 27DBB52A0DEE059700616D85 /* Red.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Red.png; sourceTree = "<group>"; };
1.42 + 27DBB52B0DEE059700616D85 /* Violet.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Violet.png; sourceTree = "<group>"; };
1.43 29B97316FDCFA39411CA2CEA /* main-iPhone.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "main-iPhone.m"; path = "Source/main-iPhone.m"; sourceTree = "<group>"; };
1.44 32CA4F630368D1EE00C91783 /* GGB-iPhone_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "GGB-iPhone_Prefix.pch"; path = "Source/GGB-iPhone_Prefix.pch"; sourceTree = "<group>"; };
1.45 8D1107310486CEB800E47090 /* Info-iPhone.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-iPhone.plist"; sourceTree = "<group>"; };
1.46 @@ -150,7 +164,7 @@
1.47 19C28FACFE9D520D11CA2CBB /* Products */ = {
1.48 isa = PBXGroup;
1.49 children = (
1.50 - 1D6058910D05DD3D006BFB54 /* GGB-iPhone.app */,
1.51 + 1D6058910D05DD3D006BFB54 /* GeekGameBoard.app */,
1.52 );
1.53 name = Products;
1.54 sourceTree = "<group>";
1.55 @@ -230,6 +244,18 @@
1.56 name = Games;
1.57 sourceTree = "<group>";
1.58 };
1.59 + 27DBB5260DEE059700616D85 /* Gingko */ = {
1.60 + isa = PBXGroup;
1.61 + children = (
1.62 + 27DBB5270DEE059700616D85 /* Blue.png */,
1.63 + 27DBB5280DEE059700616D85 /* Gold.png */,
1.64 + 27DBB5290DEE059700616D85 /* Green.png */,
1.65 + 27DBB52A0DEE059700616D85 /* Red.png */,
1.66 + 27DBB52B0DEE059700616D85 /* Violet.png */,
1.67 + );
1.68 + path = Gingko;
1.69 + sourceTree = "<group>";
1.70 + };
1.71 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = {
1.72 isa = PBXGroup;
1.73 children = (
1.74 @@ -258,14 +284,17 @@
1.75 29B97317FDCFA39411CA2CEA /* Resources */ = {
1.76 isa = PBXGroup;
1.77 children = (
1.78 + 274050290DEF36DF0006A9EE /* Pop.aiff */,
1.79 + 2740502A0DEF36DF0006A9EE /* Tink.aiff */,
1.80 279F4E050D860B8800B32DBF /* Green Ball.png */,
1.81 279F4E060D860B8800B32DBF /* Red Ball.png */,
1.82 279F4E070D860B8800B32DBF /* White Ball.png */,
1.83 - 279F4F1A0D86448100B32DBF /* Wood.jpg */,
1.84 279F4E090D860B8800B32DBF /* Yellow Ball.png */,
1.85 - 279F4C730D85D43800B32DBF /* Background.png */,
1.86 279F4C1C0D85D0AF00B32DBF /* X.tiff */,
1.87 279F4C1E0D85D0CB00B32DBF /* O.tiff */,
1.88 + 279F4F1A0D86448100B32DBF /* Wood.jpg */,
1.89 + 27DBB5260DEE059700616D85 /* Gingko */,
1.90 + 279F4C730D85D43800B32DBF /* Background.png */,
1.91 279F4B720D85CDE900B32DBF /* ToolbarAdvanced.icns */,
1.92 8D1107310486CEB800E47090 /* Info-iPhone.plist */,
1.93 );
1.94 @@ -298,7 +327,7 @@
1.95 );
1.96 name = "GGB-iPhone";
1.97 productName = "GGB-iPhone";
1.98 - productReference = 1D6058910D05DD3D006BFB54 /* GGB-iPhone.app */;
1.99 + productReference = 1D6058910D05DD3D006BFB54 /* GeekGameBoard.app */;
1.100 productType = "com.apple.product-type.application";
1.101 };
1.102 /* End PBXNativeTarget section */
1.103 @@ -332,6 +361,13 @@
1.104 279F4E0C0D860B8800B32DBF /* White Ball.png in Resources */,
1.105 279F4E0E0D860B8800B32DBF /* Yellow Ball.png in Resources */,
1.106 279F4F1B0D86448100B32DBF /* Wood.jpg in Resources */,
1.107 + 27DBB52C0DEE059700616D85 /* Blue.png in Resources */,
1.108 + 27DBB52D0DEE059800616D85 /* Gold.png in Resources */,
1.109 + 27DBB52E0DEE059800616D85 /* Green.png in Resources */,
1.110 + 27DBB52F0DEE059900616D85 /* Red.png in Resources */,
1.111 + 27DBB5300DEE059900616D85 /* Violet.png in Resources */,
1.112 + 2740502B0DEF36DF0006A9EE /* Pop.aiff in Resources */,
1.113 + 2740502C0DEF36DF0006A9EE /* Tink.aiff in Resources */,
1.114 );
1.115 runOnlyForDeploymentPostprocessing = 0;
1.116 };
1.117 @@ -384,7 +420,7 @@
1.118 GCC_PREFIX_HEADER = "Source/GGB-iPhone_Prefix.pch";
1.119 INFOPLIST_FILE = "Resources/Info-iPhone.plist";
1.120 PREBINDING = NO;
1.121 - PRODUCT_NAME = "GGB-iPhone";
1.122 + PRODUCT_NAME = GeekGameBoard;
1.123 };
1.124 name = Debug;
1.125 };
1.126 @@ -398,7 +434,7 @@
1.127 GCC_PREFIX_HEADER = "Source/GGB-iPhone_Prefix.pch";
1.128 INFOPLIST_FILE = "Resources/Info-iPhone.plist";
1.129 PREBINDING = NO;
1.130 - PRODUCT_NAME = "GGB-iPhone";
1.131 + PRODUCT_NAME = GeekGameBoard;
1.132 WRAPPER_EXTENSION = app;
1.133 };
1.134 name = Release;
1.135 @@ -429,6 +465,7 @@
1.136 "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Laurence ANDERSEN";
1.137 GCC_C_LANGUAGE_STANDARD = gnu99;
1.138 GCC_TREAT_WARNINGS_AS_ERRORS = YES;
1.139 + GCC_WARN_ABOUT_RETURN_TYPE = YES;
1.140 PREBINDING = NO;
1.141 SDKROOT = iphoneos2.0;
1.142 WARNING_CFLAGS = "-Wall";
2.1 --- a/GeekGameBoard.xcodeproj/project.pbxproj Wed May 28 12:47:10 2008 -0700
2.2 +++ b/GeekGameBoard.xcodeproj/project.pbxproj Thu May 29 15:04:06 2008 -0700
2.3 @@ -19,6 +19,11 @@
2.4 2734B2620CC7F25A0070C008 /* HexchequerGame.m in Sources */ = {isa = PBXBuildFile; fileRef = 2734B2610CC7F25A0070C008 /* HexchequerGame.m */; };
2.5 2734B4F00CCA5BDB0070C008 /* CheckersGame.m in Sources */ = {isa = PBXBuildFile; fileRef = 2734B4EF0CCA5BDB0070C008 /* CheckersGame.m */; };
2.6 274124060CFCCF9D00842A9B /* DemoBoardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 274124050CFCCF9D00842A9B /* DemoBoardView.m */; };
2.7 + 275167D90DEE2AB000247375 /* Blue.png in Resources */ = {isa = PBXBuildFile; fileRef = 275167D40DEE2AB000247375 /* Blue.png */; };
2.8 + 275167DA0DEE2AB000247375 /* Gold.png in Resources */ = {isa = PBXBuildFile; fileRef = 275167D50DEE2AB000247375 /* Gold.png */; };
2.9 + 275167DB0DEE2AB000247375 /* Green.png in Resources */ = {isa = PBXBuildFile; fileRef = 275167D60DEE2AB000247375 /* Green.png */; };
2.10 + 275167DC0DEE2AB000247375 /* Red.png in Resources */ = {isa = PBXBuildFile; fileRef = 275167D70DEE2AB000247375 /* Red.png */; };
2.11 + 275167DD0DEE2AB000247375 /* Violet.png in Resources */ = {isa = PBXBuildFile; fileRef = 275167D80DEE2AB000247375 /* Violet.png */; };
2.12 276DFC410D00867000D329AE /* Green Ball.png in Resources */ = {isa = PBXBuildFile; fileRef = 276DFC400D00867000D329AE /* Green Ball.png */; };
2.13 276DFC560D00890C00D329AE /* Red Ball.png in Resources */ = {isa = PBXBuildFile; fileRef = 276DFC530D00890C00D329AE /* Red Ball.png */; };
2.14 276DFC570D00890C00D329AE /* Yellow Ball.png in Resources */ = {isa = PBXBuildFile; fileRef = 276DFC540D00890C00D329AE /* Yellow Ball.png */; };
2.15 @@ -73,6 +78,11 @@
2.16 2734B4EF0CCA5BDB0070C008 /* CheckersGame.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CheckersGame.m; sourceTree = "<group>"; };
2.17 274124040CFCCF9D00842A9B /* DemoBoardView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoBoardView.h; sourceTree = "<group>"; };
2.18 274124050CFCCF9D00842A9B /* DemoBoardView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DemoBoardView.m; sourceTree = "<group>"; };
2.19 + 275167D40DEE2AB000247375 /* Blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Blue.png; sourceTree = "<group>"; };
2.20 + 275167D50DEE2AB000247375 /* Gold.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Gold.png; sourceTree = "<group>"; };
2.21 + 275167D60DEE2AB000247375 /* Green.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Green.png; sourceTree = "<group>"; };
2.22 + 275167D70DEE2AB000247375 /* Red.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Red.png; sourceTree = "<group>"; };
2.23 + 275167D80DEE2AB000247375 /* Violet.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Violet.png; sourceTree = "<group>"; };
2.24 276DFC400D00867000D329AE /* Green Ball.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Green Ball.png"; path = "Resources/Green Ball.png"; sourceTree = "<group>"; };
2.25 276DFC530D00890C00D329AE /* Red Ball.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Red Ball.png"; path = "Resources/Red Ball.png"; sourceTree = "<group>"; };
2.26 276DFC540D00890C00D329AE /* Yellow Ball.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Yellow Ball.png"; path = "Resources/Yellow Ball.png"; sourceTree = "<group>"; };
2.27 @@ -235,6 +245,19 @@
2.28 name = Games;
2.29 sourceTree = "<group>";
2.30 };
2.31 + 275167D30DEE2AB000247375 /* Gingko */ = {
2.32 + isa = PBXGroup;
2.33 + children = (
2.34 + 275167D40DEE2AB000247375 /* Blue.png */,
2.35 + 275167D50DEE2AB000247375 /* Gold.png */,
2.36 + 275167D60DEE2AB000247375 /* Green.png */,
2.37 + 275167D70DEE2AB000247375 /* Red.png */,
2.38 + 275167D80DEE2AB000247375 /* Violet.png */,
2.39 + );
2.40 + name = Gingko;
2.41 + path = Resources/Gingko;
2.42 + sourceTree = "<group>";
2.43 + };
2.44 29B97314FDCFA39411CA2CEA /* BoardGame */ = {
2.45 isa = PBXGroup;
2.46 children = (
2.47 @@ -262,6 +285,7 @@
2.48 29B97317FDCFA39411CA2CEA /* Resources */ = {
2.49 isa = PBXGroup;
2.50 children = (
2.51 + 275167D30DEE2AB000247375 /* Gingko */,
2.52 29B97318FDCFA39411CA2CEA /* MainMenu.nib */,
2.53 8D1107310486CEB800E47090 /* Info.plist */,
2.54 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
2.55 @@ -339,6 +363,11 @@
2.56 279F4DB20D8607AD00B32DBF /* O.tiff in Resources */,
2.57 279F4DB30D8607AD00B32DBF /* X.tiff in Resources */,
2.58 279F4DE20D8609C200B32DBF /* Background.png in Resources */,
2.59 + 275167D90DEE2AB000247375 /* Blue.png in Resources */,
2.60 + 275167DA0DEE2AB000247375 /* Gold.png in Resources */,
2.61 + 275167DB0DEE2AB000247375 /* Green.png in Resources */,
2.62 + 275167DC0DEE2AB000247375 /* Red.png in Resources */,
2.63 + 275167DD0DEE2AB000247375 /* Violet.png in Resources */,
2.64 );
2.65 runOnlyForDeploymentPostprocessing = 0;
2.66 };
3.1 --- a/Source/Bit.h Wed May 28 12:47:10 2008 -0700
3.2 +++ b/Source/Bit.h Thu May 29 15:04:06 2008 -0700
3.3 @@ -29,7 +29,7 @@
3.4
3.5 /** Standard Z positions */
3.6 enum {
3.7 - kBoardZ = 1,
3.8 + kBoardZ = 0,
3.9 kCardZ = 2,
3.10 kPieceZ = 3,
3.11
3.12 @@ -43,6 +43,7 @@
3.13 {
3.14 @private
3.15 int _restingZ; // Original z position, saved while pickedUp
3.16 + BOOL _pickedUp;
3.17 Player *_owner; // Player that owns this Bit
3.18 }
3.19
4.1 --- a/Source/Bit.m Wed May 28 12:47:10 2008 -0700
4.2 +++ b/Source/Bit.m Thu May 29 15:04:06 2008 -0700
4.3 @@ -25,6 +25,15 @@
4.4 #import "QuartzUtils.h"
4.5
4.6
4.7 +#ifdef TARGET_OS_IPHONE
4.8 +#define kPickedUpScale 2.0 // more magnification, so piece shows up underneath fingertip
4.9 +#define kPickedUpOpacity 0.6
4.10 +#else
4.11 +#define kPickedUpScale 1.2
4.12 +#define kPickedUpOpacity 0.9
4.13 +#endif
4.14 +
4.15 +
4.16 @implementation Bit
4.17
4.18
4.19 @@ -84,29 +93,29 @@
4.20
4.21 - (BOOL) pickedUp
4.22 {
4.23 - return self.zPosition >= kPickedUpZ;
4.24 + return _pickedUp;
4.25 }
4.26
4.27 - (void) setPickedUp: (BOOL)up
4.28 {
4.29 - if( up != self.pickedUp ) {
4.30 + if( up != _pickedUp ) {
4.31 CGFloat shadow, offset, radius, opacity, z, scale;
4.32 if( up ) {
4.33 shadow = 0.8;
4.34 offset = 2;
4.35 radius = 8;
4.36 - opacity = 0.9;
4.37 - scale = 1.2;
4.38 + opacity = kPickedUpOpacity;
4.39 + scale = kPickedUpScale;
4.40 z = kPickedUpZ;
4.41 _restingZ = self.zPosition;
4.42 } else {
4.43 shadow = offset = radius = 0.0;
4.44 opacity = 1.0;
4.45 - scale = 1.0/1.2;
4.46 + scale = 1.0/kPickedUpScale;
4.47 z = _restingZ;
4.48 }
4.49 -
4.50 - self.zPosition = z;
4.51 +
4.52 + //self.zPosition = z;
4.53 #if !TARGET_OS_IPHONE
4.54 self.shadowOpacity = shadow;
4.55 self.shadowOffset = CGSizeMake(offset,-offset);
4.56 @@ -114,6 +123,7 @@
4.57 #endif
4.58 self.opacity = opacity;
4.59 self.scale *= scale;
4.60 + _pickedUp = up;
4.61 }
4.62 }
4.63
5.1 --- a/Source/BoardUIView.m Wed May 28 12:47:10 2008 -0700
5.2 +++ b/Source/BoardUIView.m Thu May 29 15:04:06 2008 -0700
5.3 @@ -199,11 +199,9 @@
5.4 CGPoint newPos = [_dragBit.superlayer convertPoint: pos fromLayer: self.layer];
5.5
5.6 [CATransaction flush];
5.7 - [CATransaction begin];
5.8 - [CATransaction setValue:(id)kCFBooleanTrue
5.9 - forKey:kCATransactionDisableActions];
5.10 + BeginDisableAnimations();
5.11 _dragBit.position = newPos;
5.12 - [CATransaction commit];
5.13 + EndDisableAnimations();
5.14
5.15 // Find what it's over:
5.16 [self _findDropTarget: pos];
5.17 @@ -261,6 +259,7 @@
5.18 } else {
5.19 [_dragBit removeFromSuperlayer];
5.20 }
5.21 + Beep();
5.22 }
5.23 } else {
5.24 // Just a click, without a drag:
6.1 --- a/Source/BoardView.m Wed May 28 12:47:10 2008 -0700
6.2 +++ b/Source/BoardView.m Thu May 29 15:04:06 2008 -0700
6.3 @@ -301,6 +301,7 @@
6.4 if( ! [_game clickedBit: _dragBit] )
6.5 NSBeep();
6.6 }
6.7 +
6.8 _dropTarget = nil;
6.9 _dragBit = nil;
6.10 [NSCursor pop];
7.1 --- a/Source/CheckersGame.m Wed May 28 12:47:10 2008 -0700
7.2 +++ b/Source/CheckersGame.m Thu May 29 15:04:06 2008 -0700
7.3 @@ -32,8 +32,8 @@
7.4
7.5 - (Piece*) pieceForPlayer: (int)playerNum
7.6 {
7.7 - Piece *p = [[Piece alloc] initWithImageNamed: (playerNum==0 ?@"Green Ball.png" :@"Red Ball.png")
7.8 - scale: floor(_grid.spacing.width * 0.8)];
7.9 + Piece *p = [[Piece alloc] initWithImageNamed: (playerNum==0 ?@"Green.png" :@"Red.png")
7.10 + scale: floor(_grid.spacing.width * 1.0)];
7.11 p.owner = [self.players objectAtIndex: playerNum];
7.12 p.name = playerNum ?@"2" :@"1";
7.13 return [p autorelease];
8.1 --- a/Source/Dispenser.m Wed May 28 12:47:10 2008 -0700
8.2 +++ b/Source/Dispenser.m Thu May 29 15:04:06 2008 -0700
8.3 @@ -72,14 +72,12 @@
8.4 {
8.5 NSAssert(_bit==nil,@"Already have a currentBit");
8.6
8.7 - [CATransaction begin];
8.8 - [CATransaction setValue: (id)kCFBooleanTrue
8.9 - forKey: kCATransactionDisableActions];
8.10 + BeginDisableAnimations();
8.11 self.bit = [self createBit];
8.12 CGPoint pos = _bit.position;
8.13 _bit.position = CGPointMake(pos.x, pos.y+70);
8.14 [self addSublayer: _bit];
8.15 - [CATransaction commit];
8.16 + EndDisableAnimations();
8.17
8.18 _bit.position = pos;
8.19 }
9.1 --- a/Source/GGBLayer.h Wed May 28 12:47:10 2008 -0700
9.2 +++ b/Source/GGBLayer.h Thu May 29 15:04:06 2008 -0700
9.3 @@ -36,3 +36,14 @@
9.4 - (void) animateAndBlock: (NSString*)keyPath from: (id)from to: (id)to duration: (NSTimeInterval)duration;
9.5
9.6 @end
9.7 +
9.8 +
9.9 +/** Moves a layer from one superlayer to another, without changing its position onscreen. */
9.10 +void ChangeSuperlayer( CALayer *layer, CALayer *newSuperlayer, int index );
9.11 +
9.12 +/** Removes a layer from its superlayer without any fade-out animation. */
9.13 +void RemoveImmediately( CALayer *layer );
9.14 +
9.15 +/** Disables animations until EndDisableAnimations is called. */
9.16 +void BeginDisableAnimations(void);
9.17 +void EndDisableAnimations(void);
10.1 --- a/Source/GGBLayer.m Wed May 28 12:47:10 2008 -0700
10.2 +++ b/Source/GGBLayer.m Thu May 29 15:04:06 2008 -0700
10.3 @@ -116,6 +116,7 @@
10.4
10.5 - (CGFloat) cornerRadius {return _cornerRadius;}
10.6 - (CGFloat) borderWidth {return _borderWidth;}
10.7 +- (CGColorRef) backgroundColor {return _realBGColor;}
10.8 - (CGColorRef) borderColor {return _borderColor;}
10.9
10.10 - (void) setCornerRadius: (CGFloat)r
10.11 @@ -236,3 +237,54 @@
10.12
10.13
10.14 @end
10.15 +
10.16 +
10.17 +
10.18 +#pragma mark -
10.19 +#pragma mark UTILITIES:
10.20 +
10.21 +
10.22 +void BeginDisableAnimations(void)
10.23 +{
10.24 + [CATransaction begin];
10.25 + [CATransaction setValue:(id)kCFBooleanTrue
10.26 + forKey:kCATransactionDisableActions];
10.27 +}
10.28 +
10.29 +void EndDisableAnimations(void)
10.30 +{
10.31 + [CATransaction commit];
10.32 +}
10.33 +
10.34 +
10.35 +void ChangeSuperlayer( CALayer *layer, CALayer *newSuperlayer, int index )
10.36 +{
10.37 + // Disable actions, else the layer will move to the wrong place and then back!
10.38 + [CATransaction flush];
10.39 + BeginDisableAnimations();
10.40 +
10.41 + CGPoint pos = layer.position;
10.42 + if( layer.superlayer )
10.43 + pos = [newSuperlayer convertPoint: pos fromLayer: layer.superlayer];
10.44 + [layer retain];
10.45 + [layer removeFromSuperlayer];
10.46 + layer.position = pos;
10.47 + if( index >= 0 )
10.48 + [newSuperlayer insertSublayer: layer atIndex: index];
10.49 + else
10.50 + [newSuperlayer addSublayer: layer];
10.51 + [layer release];
10.52 +
10.53 + EndDisableAnimations();
10.54 +}
10.55 +
10.56 +
10.57 +void RemoveImmediately( CALayer *layer )
10.58 +{
10.59 + [CATransaction flush];
10.60 + BeginDisableAnimations();
10.61 + [layer removeFromSuperlayer];
10.62 + EndDisableAnimations();
10.63 +}
10.64 +
10.65 +
11.1 --- a/Source/GGBTextLayer.m Wed May 28 12:47:10 2008 -0700
11.2 +++ b/Source/GGBTextLayer.m Thu May 29 15:04:06 2008 -0700
11.3 @@ -61,14 +61,15 @@
11.4 label.alignmentMode = mode;
11.5
11.6 // Get the bounds of the interior of the superlayer:
11.7 - CGFloat inset = round(font.pointSize/8);
11.8 + CGFloat yinset = 0;
11.9 if( [superlayer respondsToSelector: @selector(borderWidth)] )
11.10 - inset += ((GGBLayer*)superlayer).borderWidth;
11.11 - CGRect bounds = CGRectInset(superlayer.bounds, inset, inset);
11.12 - if( mode==@"center" ) {
11.13 - // horizontal centering: ignore x inset:
11.14 - bounds = CGRectInset(bounds,-inset,0);
11.15 - }
11.16 + yinset += ((GGBLayer*)superlayer).borderWidth;
11.17 + CGFloat xinset;
11.18 + if( mode==@"center" )
11.19 + xinset = 0;
11.20 + else
11.21 + xinset = yinset + round(font.pointSize/3.0);
11.22 + CGRect bounds = CGRectInset(superlayer.bounds, xinset,yinset);
11.23
11.24 // Compute y position of bottom of layer's frame. (Remember, descender is negative!)
11.25 CGFloat y = bounds.origin.y;
12.1 --- a/Source/GGBUtils.m Wed May 28 12:47:10 2008 -0700
12.2 +++ b/Source/GGBUtils.m Thu May 29 15:04:06 2008 -0700
12.3 @@ -42,9 +42,47 @@
12.4 }
12.5
12.6
12.7 +#if TARGET_OS_IPHONE
12.8 +static SystemSoundID GetSound( NSString *name )
12.9 +{
12.10 + static NSMutableDictionary *sSoundIDs;
12.11 + NSNumber *soundIDObj = [sSoundIDs objectForKey: name];
12.12 + if( ! soundIDObj ) {
12.13 + NSLog(@"Loading sound '%@'",name);
12.14 + NSString *type = name.pathExtension;
12.15 + if( ! type.length )
12.16 + type = @"aiff";
12.17 + NSString *path = [[NSBundle mainBundle] pathForResource: name.stringByDeletingPathExtension
12.18 + ofType: type];
12.19 + NSURL *url;
12.20 + if( path )
12.21 + url = [NSURL fileURLWithPath: path];
12.22 + else {
12.23 + NSLog(@"Couldn't find sound %@",name);
12.24 + return 0;
12.25 + }
12.26 + //url = [NSURL fileURLWithPath: [@"/Library/Sounds/" stringByAppendingPathComponent: name]];
12.27 + SystemSoundID soundID;
12.28 + if( AudioServicesCreateSystemSoundID((CFURLRef)url,&soundID) != noErr ) {
12.29 + NSLog(@"Couldn't load sound %@",url);
12.30 + return 0;
12.31 + }
12.32 +
12.33 + soundIDObj = [NSNumber numberWithUnsignedInt: soundID];
12.34 + if( ! sSoundIDs )
12.35 + sSoundIDs = [[NSMutableDictionary alloc] init];
12.36 + [sSoundIDs setObject: soundIDObj forKey: name];
12.37 + }
12.38 + return [soundIDObj unsignedIntValue];
12.39 +}
12.40 +#endif
12.41 +
12.42 +
12.43 void PreloadSound( NSString* name )
12.44 {
12.45 -#if ! TARGET_OS_IPHONE
12.46 +#if TARGET_OS_IPHONE
12.47 + GetSound(name);
12.48 +#else
12.49 NSSound *sound = [[NSSound soundNamed: @"Pop"] copy];
12.50 sound.volume = 0;
12.51 [sound play];
12.52 @@ -56,13 +94,7 @@
12.53 void PlaySound( NSString* name )
12.54 {
12.55 #if TARGET_OS_IPHONE
12.56 - NSURL *url = [NSURL fileURLWithPath: [@"/Library/Sounds/" stringByAppendingPathComponent: name]];
12.57 - SystemSoundID soundID;
12.58 - if( AudioServicesCreateSystemSoundID((CFURLRef)url,&soundID) != noErr ) {
12.59 - NSLog(@"Couldn't load sound %@",url);
12.60 - return;
12.61 - }
12.62 - AudioServicesPlaySystemSound(soundID);
12.63 + AudioServicesPlaySystemSound( GetSound(name) );
12.64 #else
12.65 [[NSSound soundNamed: name] play];
12.66 #endif
12.67 @@ -71,7 +103,7 @@
12.68 void Beep()
12.69 {
12.70 #if TARGET_OS_IPHONE
12.71 - AudioServicesPlayAlertSound(0x00001000/*kSystemSoundID_UserPreferredAlert*/);
12.72 + AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
12.73 #else
12.74 NSBeep();
12.75 #endif
13.1 --- a/Source/Game.m Wed May 28 12:47:10 2008 -0700
13.2 +++ b/Source/Game.m Thu May 29 15:04:06 2008 -0700
13.3 @@ -196,11 +196,9 @@
13.4 if( turn==_currentTurn+1 ) {
13.5 [self applyMoveString: [_moves objectAtIndex: _currentTurn]];
13.6 } else {
13.7 - [CATransaction begin];
13.8 - [CATransaction setValue:(id)kCFBooleanTrue
13.9 - forKey:kCATransactionDisableActions];
13.10 + BeginDisableAnimations();
13.11 self.stateString = [_states objectAtIndex: turn];
13.12 - [CATransaction commit];
13.13 + EndDisableAnimations();
13.14 }
13.15 _currentTurn = turn;
13.16 self.currentPlayer = [_players objectAtIndex: (turn % _players.count)];
14.1 --- a/Source/Piece.h Wed May 28 12:47:10 2008 -0700
14.2 +++ b/Source/Piece.h Thu May 29 15:04:06 2008 -0700
14.3 @@ -38,10 +38,12 @@
14.4 - (id) initWithImageNamed: (NSString*)imageName
14.5 scale: (CGFloat)scale;
14.6
14.7 +- (void) setImageNamed: (NSString*)imageName scale: (CGFloat)scale;
14.8 - (void) setImage: (CGImageRef)image scale: (CGFloat)scale;
14.9 - (void) setImage: (CGImageRef)image;
14.10 - (void) setImageNamed: (NSString*)name;
14.11
14.12 @property (copy) NSString* imageName;
14.13
14.14 +
14.15 @end
15.1 --- a/Source/Piece.m Wed May 28 12:47:10 2008 -0700
15.2 +++ b/Source/Piece.m Thu May 29 15:04:06 2008 -0700
15.3 @@ -32,8 +32,7 @@
15.4 {
15.5 self = [super init];
15.6 if (self != nil) {
15.7 - self.imageName = imageName;
15.8 - [self setImage: GetCGImageNamed(imageName) scale: scale];
15.9 + [self setImageNamed: imageName scale: scale];
15.10 self.zPosition = kPieceZ;
15.11 }
15.12 return self;
15.13 @@ -66,20 +65,25 @@
15.14 @synthesize imageName=_imageName;
15.15
15.16
15.17 +- (void) _setImage: (CGImageRef)image
15.18 +{
15.19 + self.contents = (id) image;
15.20 + self.bounds = CGRectMake(0,0,CGImageGetWidth(image),CGImageGetHeight(image));
15.21 + self.contentsGravity = kCAGravityResizeAspect;
15.22 + self.minificationFilter = kCAFilterLinear;
15.23 + self.imageName = nil;
15.24 +}
15.25 +
15.26 +
15.27 - (void) setImage: (CGImageRef)image scale: (CGFloat)scale
15.28 {
15.29 - self.contents = (id) image;
15.30 - self.contentsGravity = @"resize";
15.31 - self.minificationFilter = kCAFilterLinear;
15.32 - int width = CGImageGetWidth(image), height = CGImageGetHeight(image);
15.33 - if( scale > 0 ) {
15.34 - if( scale >= 4.0 )
15.35 - scale /= MAX(width,height); // interpret scale as target dimensions
15.36 - width = ceil( width * scale);
15.37 - height= ceil( height* scale);
15.38 - }
15.39 - self.bounds = CGRectMake(0,0,width,height);
15.40 - self.imageName = nil;
15.41 + [self _setImage: CreateScaledImage(image,scale)];
15.42 +}
15.43 +
15.44 +- (void) setImageNamed: (NSString*)imageName scale: (CGFloat)scale
15.45 +{
15.46 + [self _setImage: GetScaledImageNamed(imageName,scale)];
15.47 + self.imageName = imageName;
15.48 }
15.49
15.50 - (void) setImage: (CGImageRef)image
16.1 --- a/Source/QuartzUtils.h Wed May 28 12:47:10 2008 -0700
16.2 +++ b/Source/QuartzUtils.h Thu May 29 15:04:06 2008 -0700
16.3 @@ -39,13 +39,6 @@
16.4 #endif
16.5
16.6
16.7 -/** Moves a layer from one superlayer to another, without changing its position onscreen. */
16.8 -void ChangeSuperlayer( CALayer *layer, CALayer *newSuperlayer, int index );
16.9 -
16.10 -/** Removes a layer from its superlayer without any fade-out animation. */
16.11 -void RemoveImmediately( CALayer *layer );
16.12 -
16.13 -
16.14 /** Loads an image or pattern file into a CGImage or CGPattern.
16.15 If the name begins with "/", it's interpreted as an absolute filesystem path.
16.16 Otherwise, it's the name of a resource that's looked up in the app bundle.
16.17 @@ -61,6 +54,9 @@
16.18 CGImageRef GetCGImageFromPasteboard( NSPasteboard *pb );
16.19 #endif
16.20
16.21 +CGImageRef CreateScaledImage( CGImageRef srcImage, CGFloat scale );
16.22 +CGImageRef GetScaledImageNamed( NSString *imageName, CGFloat scale );
16.23 +
16.24 /** Creates a CGPattern from a CGImage. Caller must release it. */
16.25 CGPatternRef CreateImagePattern( CGImageRef image );
16.26
17.1 --- a/Source/QuartzUtils.m Wed May 28 12:47:10 2008 -0700
17.2 +++ b/Source/QuartzUtils.m Thu May 29 15:04:06 2008 -0700
17.3 @@ -22,6 +22,7 @@
17.4 */
17.5 #import "QuartzUtils.h"
17.6 #import <QuartzCore/QuartzCore.h>
17.7 +#import "Piece.h"
17.8
17.9
17.10 CGColorRef kBlackColor, kWhiteColor,
17.11 @@ -63,41 +64,6 @@
17.12 #endif
17.13
17.14
17.15 -void ChangeSuperlayer( CALayer *layer, CALayer *newSuperlayer, int index )
17.16 -{
17.17 - // Disable actions, else the layer will move to the wrong place and then back!
17.18 - [CATransaction flush];
17.19 - [CATransaction begin];
17.20 - [CATransaction setValue:(id)kCFBooleanTrue
17.21 - forKey:kCATransactionDisableActions];
17.22 -
17.23 - CGPoint pos = layer.position;
17.24 - if( layer.superlayer )
17.25 - pos = [newSuperlayer convertPoint: pos fromLayer: layer.superlayer];
17.26 - [layer retain];
17.27 - [layer removeFromSuperlayer];
17.28 - layer.position = pos;
17.29 - if( index >= 0 )
17.30 - [newSuperlayer insertSublayer: layer atIndex: index];
17.31 - else
17.32 - [newSuperlayer addSublayer: layer];
17.33 - [layer release];
17.34 -
17.35 - [CATransaction commit];
17.36 -}
17.37 -
17.38 -
17.39 -void RemoveImmediately( CALayer *layer )
17.40 -{
17.41 - [CATransaction flush];
17.42 - [CATransaction begin];
17.43 - [CATransaction setValue:(id)kCFBooleanTrue
17.44 - forKey:kCATransactionDisableActions];
17.45 - [layer removeFromSuperlayer];
17.46 - [CATransaction commit];
17.47 -}
17.48 -
17.49 -
17.50 CGImageRef CreateCGImageFromFile( NSString *path )
17.51 {
17.52 #if TARGET_OS_IPHONE
17.53 @@ -195,6 +161,47 @@
17.54 #endif
17.55
17.56
17.57 +CGImageRef CreateScaledImage( CGImageRef srcImage, CGFloat scale )
17.58 +{
17.59 + int width = CGImageGetWidth(srcImage), height = CGImageGetHeight(srcImage);
17.60 + if( scale > 0 ) {
17.61 + if( scale >= 4.0 )
17.62 + scale /= MAX(width,height); // interpret scale as target dimensions
17.63 + width = ceil( width * scale);
17.64 + height= ceil( height* scale);
17.65 + }
17.66 +
17.67 + CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
17.68 + CGContextRef ctx = CGBitmapContextCreate(NULL, width, height, 8, 4*width, space,
17.69 + kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast);
17.70 + CGColorSpaceRelease(space);
17.71 + CGContextSetInterpolationQuality(ctx,kCGInterpolationHigh);
17.72 + CGContextDrawImage(ctx, CGRectMake(0, 0, width, height), srcImage);
17.73 + CGImageRef dstImage = CGBitmapContextCreateImage(ctx);
17.74 + CGContextRelease(ctx);
17.75 + return dstImage;
17.76 +}
17.77 +
17.78 +
17.79 +CGImageRef GetScaledImageNamed( NSString *imageName, CGFloat scale )
17.80 +{
17.81 + // For efficiency, loaded images are cached in a dictionary by name.
17.82 + static NSMutableDictionary *sMap;
17.83 + if( ! sMap )
17.84 + sMap = [[NSMutableDictionary alloc] init];
17.85 +
17.86 + NSArray *key = [NSArray arrayWithObjects: imageName, [NSNumber numberWithFloat: scale], nil];
17.87 + CGImageRef image = (CGImageRef) [sMap objectForKey: key];
17.88 + if( ! image ) {
17.89 + // Hasn't been cached yet, so load it:
17.90 + image = CreateScaledImage(GetCGImageNamed(imageName), scale);
17.91 + [sMap setObject: (id)image forKey: key];
17.92 + CGImageRelease(image);
17.93 + }
17.94 + return image;
17.95 +}
17.96 +
17.97 +
17.98 float GetPixelAlpha( CGImageRef image, CGSize imageSize, CGPoint pt )
17.99 {
17.100 #if TARGET_OS_IPHONE
18.1 --- a/Source/iPhoneAppDelegate.m Wed May 28 12:47:10 2008 -0700
18.2 +++ b/Source/iPhoneAppDelegate.m Thu May 29 15:04:06 2008 -0700
18.3 @@ -13,6 +13,19 @@
18.4 #import "GGBUtils.h"
18.5
18.6
18.7 +// Temporary HACK to fix logging problem in beta 6 iPhone OS
18.8 +extern void _NSSetLogCStringFunction(void (*)(const char *string, unsigned length, BOOL withSyslogBanner));
18.9 +static void PrintNSLogMessage(const char *string, unsigned length, BOOL withSyslogBanner)
18.10 +{
18.11 + puts(string);
18.12 +}
18.13 +static void HackNSLog(void) __attribute__((constructor));
18.14 +static void HackNSLog(void)
18.15 +{
18.16 + _NSSetLogCStringFunction(PrintNSLogMessage);
18.17 +}
18.18 +
18.19 +
18.20 @implementation GGB_iPhoneAppDelegate
18.21
18.22
18.23 @@ -23,9 +36,6 @@
18.24
18.25 - (void)applicationDidFinishLaunching:(UIApplication *)application
18.26 {
18.27 - for( NSString *family in [UIFont familyNames] )
18.28 - NSLog(@"%@: (%@)", family, [[UIFont fontNamesForFamilyName: family] componentsJoinedByString: @", "]);
18.29 -
18.30 // Create window
18.31 self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
18.32 _window.layer.backgroundColor = GetCGPatternNamed(@"Background.png");
18.33 @@ -48,7 +58,7 @@
18.34 [_window addSubview: _headline];
18.35
18.36 // Start game:
18.37 - [self startGameNamed: @"KlondikeGame"];
18.38 + [self startGameNamed: @"CheckersGame"];
18.39
18.40 // Show window
18.41 [_window makeKeyAndVisible];