[Objective-C] Cocos2D and Google Analytics Category

//  Created by Danilo Priore on 20/02/13.
//  www.prioregroup.com

// CCLayer+GoogleAnalytics.h
#import "CCLayer.h"

@interface CCLayer (GoogleAnalytics)

// 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"])

#ifndef DEBUG
    // track of the specified view was displayed
    [[GAI sharedInstance].defaultTracker sendView:className];
    NSLog(@"Class Name: %@", className);
// original code of CCLayer
	if( isAccelerometerEnabled_ )
		[[UIAccelerometer sharedAccelerometer] setDelegate:self];
    	[super onEnterTransitionDidFinish];

Copyright © 1996-2022 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581.