Created
October 25, 2013 23:49
-
-
Save priore/7163556 to your computer and use it in GitHub Desktop.
Cocos2D and Google Analytics Category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // Created by Danilo Priore on 20/02/13. | |
| // www.prioregroup.com | |
| // | |
| // CCLayer+GoogleAnalytics.h | |
| #import "CCLayer.h" | |
| @interface CCLayer (GoogleAnalytics) | |
| @end | |
| // CCLayer+GoogleAnalytics.m | |
| import "CCLayer+GoogleAnalytics.h" | |
| #import "GAI.h" // Google Analytics SDK | |
| @implementation CCLayer (GoogleAnalytics) | |
| // overwrite original method of CCLayer | |
| - (void)onEnterTransitionDidFinish { | |
| NSString *className = NSStringFromClass([self class]); | |
| // filter only for my classes (in this case the names start with "game") | |
| if (![[className substringToIndex:4] isEqualToString:@"Game"]) | |
| return; | |
| #ifndef DEBUG | |
| // track of the specified view was displayed | |
| [[GAI sharedInstance].defaultTracker sendView:className]; | |
| #else | |
| NSLog(@"Class Name: %@", className); | |
| #endif | |
| // original code of CCLayer | |
| #ifdef __CC_PLATFORM_IOS | |
| if( isAccelerometerEnabled_ ) | |
| [[UIAccelerometer sharedAccelerometer] setDelegate:self]; | |
| #endif | |
| [super onEnterTransitionDidFinish]; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment