Permalink
Browse files

add admob layer

  • Loading branch information...
1 parent d3701cf commit 49a8bf4972190a9622c1f4081aa5c6bb29e9c878 @saberma committed May 18, 2010
View
182 AdMobDelegateProtocol.h
@@ -0,0 +1,182 @@
+/**
+ * AdMobDelegateProtocol.h
+ * AdMob iPhone SDK publisher code.
+ *
+ * Defines the AdMobDelegate protocol.
+ */
+#import <UIKit/UIKit.h>
+@class AdMobView;
+
+// Constant for use with testDevices method.
+#define ADMOB_SIMULATOR_ID @"Simulator"
+
+
+@protocol AdMobDelegate<NSObject>
+
+
+@required
+
+#pragma mark -
+#pragma mark required methods
+
+// Use this to provide a publisher id for an ad request. Get a publisher id
+// from http://www.admob.com
+- (NSString *)publisherId;
+
+// Return the current view controller (AdMobView should be part of its view heirarchy).
+// Make sure to return the root view controller (e.g. a UINavigationController, not
+// the UIViewController attached to it). If there is no UIViewController return nil.
+- (UIViewController *)currentViewController;
+
+
+@optional
+
+#pragma mark -
+#pragma mark optional notification methods
+
+// Sent when an ad request loaded an ad; this is a good opportunity to add
+// this view to the hierachy, if it has not yet been added.
+// Note that this will only ever be sent once per AdMobView, regardless of whether
+// new ads are subsequently requested in the same AdMobView.
+- (void)didReceiveAd:(AdMobView *)adView;
+
+// Sent when a AdMobView successfully makes a subsequent ad request (via requestFreshAd).
+// For example an AdView object that shows three ads in its lifetime will see the following
+// methods called: didReceiveAd:, didReceiveRefreshedAd:, and didReceiveRefreshedAd:.
+- (void)didReceiveRefreshedAd:(AdMobView *)adView;
+
+// Sent when an ad request failed to load an ad.
+// Note that this will only ever be sent once per AdMobView, regardless of whether
+// new ads are subsequently requested in the same AdMobView.
+- (void)didFailToReceiveAd:(AdMobView *)adView;
+
+// Sent when subsequent AdMobView ad requests fail (via requestFreshAd).
+- (void)didFailToReceiveRefreshedAd:(AdMobView *)adView;
+
+
+// Sent just before presenting the user a full screen view, such as a canvas page or an embedded webview,
+// in response to clicking on an ad. Use this opportunity to stop animations, time sensitive interactions, etc.
+- (void)willPresentFullScreenModal;
+
+// Sent just after presenting the user a full screen view, such as a canvas page or an embedded webview,
+// in response to clicking on an ad.
+- (void)didPresentFullScreenModal;
+
+// Sent just before dismissing a full screen view.
+- (void)willDismissFullScreenModal;
+
+// Sent just after dismissing a full screen view. Use this opportunity to
+// restart anything you may have stopped as part of -willPresentFullScreenModal:.
+- (void)didDismissFullScreenModal;
+
+// Send just before the application will close because the user clicked on an ad.
+// Clicking on any ad will either call this or willPresentFullScreenModal.
+// The normal UIApplication applicationWillTerminate: delegate method will be called
+// after this.
+- (void)applicationWillTerminateFromAd;
+
+
+#pragma mark optional appearance control methods
+
+// Specifies the ad background color, for tile+text ads.
+// Defaults to [UIColor colorWithRed:0.443 green:0.514 blue:0.631 alpha:1], which is a chrome-y color.
+// Note that the alpha channel in the provided color will be ignored and treated as 1.
+// We recommend against using a white or very light color as the background color, but
+// if you do, be sure to implement primaryTextColor and secondaryTextColor.
+// Grayscale colors won't function correctly here. Use e.g. [UIColor colorWithRed:0 green:0 blue:0 alpha:1]
+// instead of [UIColor colorWithWhite:0 alpha:1] or [UIColor blackColor].
+- (UIColor *)adBackgroundColor;
+
+// Specifies the primary text color for ads.
+// Defaults to [UIColor whiteColor].
+- (UIColor *)primaryTextColor;
+
+// Specifies the secondary text color for ads.
+// Defaults to [UIColor whiteColor].
+- (UIColor *)secondaryTextColor;
+
+
+#pragma mark optional test ad methods
+
+// Test ads are returned to these devices. Device identifiers are the same used to register
+// as a development device with Apple. To obtain a value open the Organizer
+// (Window -> Organizer from Xcode), control-click or right-click on the device's name, and
+// choose "Copy Device Identifier". Alternatively you can obtain it through code using
+// [UIDevice currentDevice].uniqueIdentifier.
+//
+// For example:
+// - (NSArray *)testDevices {
+// return [NSArray arrayWithObjects:
+// ADMOB_SIMULATOR_ID, // Simulator
+// //@"28ab37c3902621dd572509110745071f0101b124", // Test iPhone 3GS 3.0.1
+// //@"8cf09e81ef3ec5418c3450f7954e0e95db8ab200", // Test iPod 2.2.1
+// nil];
+// }
+- (NSArray *)testDevices;
+
+// If implemented, lets you specify the action type of the test ad. Defaults to @"url" (web page).
+// Does nothing if testDevices is not implemented or does not map to the current device.
+// Acceptable values are @"url", @"app", @"movie", @"itunes", @"call", @"canvas". For interstitials
+// use "video_int".
+//
+// Normally, the adservers restricts ads appropriately (e.g. no click to call ads for iPod touches).
+// However, for your testing convenience, they will return any type requested for test ads.
+- (NSString *)testAdAction;
+
+
+#pragma mark optional targeting info methods
+
+// If your application uses CoreLocation you can provide the current coordinates to help
+// provide more relevant ads to your users. Note it is against Apple's policy to use
+// CoreLocation just for serving ads.
+//
+// For example:
+// - (double)locationLatitude {
+// return myCLLocationManager.location.coordinate.latitude;
+// }
+// - (double)locationLongitude {
+// return myCLLocationManager.location.coordinate.longitude;
+// }
+// - (NSDate *)locationTimestamp {
+// return myCLLocationManager.location.timestamp;
+// }
+- (double)locationLatitude;
+- (double)locationLongitude;
+- (NSDate *)locationTimestamp;
+
+// The following functions, if implemented, provide extra information
+// for the ad request. If you happen to have this information, providing it will
+// help select better targeted ads and will improve monetization.
+//
+// Keywords and search terms should be provided as a space separated string
+// like "iPhone monetization San Mateo". We strongly recommend that
+// you NOT hard code keywords or search terms.
+//
+// Keywords are used to select better ads; search terms _restrict_ the available
+// set of ads. Note, then, that providing a search string may seriously negatively
+// impact your fill rate; we recommend using it only when the user is submitting a
+// free-text search request and you want to _only_ display ads relevant to that search.
+// In those situations, however, providing a search string can yield a significant
+// monetization boost.
+//
+// For all of these methods, if the information is not available at the time of
+// the call, you should return nil.
+- (NSString *)postalCode; // user's postal code, e.g. "94401"
+- (NSString *)areaCode; // user's area code, e.g. "415"
+- (NSDate *)dateOfBirth; // user's date of birth
+- (NSString *)gender; // user's gender (e.g. @"m" or @"f")
+- (NSString *)keywords; // keywords the user has provided or that are contextually relevant, e.g. @"twitter client iPhone"
+- (NSString *)searchString; // a search string the user has provided, e.g. @"Jasmine Tea House San Francisco"
+
+
+#pragma mark -
+#pragma mark deprecated methods
+
+// The following methods were defined in previous AdMob SDKs but are now ignored
+
+- (BOOL)useGraySpinner DEPRECATED_ATTRIBUTE;
+- (BOOL)mayAskForLocation DEPRECATED_ATTRIBUTE; // implement the location* methods instead
+- (id)location DEPRECATED_ATTRIBUTE; // implement the location* methods instead
+- (BOOL)useTestAd DEPRECATED_ATTRIBUTE; // implement the testDevices method instead
+
+@end
View
51 AdMobView.h
@@ -0,0 +1,51 @@
+/**
+ * AdMobView.h
+ * AdMob iPhone SDK publisher code.
+ *
+ * The entry point for requesting a 320x48 AdMob ad to display.
+ */
+#import <UIKit/UIKit.h>
+
+@protocol AdMobDelegate;
+
+@interface AdMobView : UIView
+
+/**
+ * Initiates an ad request and returns a view that will contain the results;
+ * the delegate is alerted when the ad is ready to display (or has failed to
+ * load); this is a good opportunity to attach the view to your hierarchy.
+ * If you already have a AdMobView with an ad loaded, and simply want to show
+ * a new ad in the same location, you may use -requestFreshAd instead (see below).
+ *
+ * This method should only be called from a run loop in default run loop mode.
+ * If you don't know what that means, you're probably ok. If in doubt, check
+ * whether ([[NSRunLoop currentRunLoop] currentMode] == NSDefaultRunLoopMode).
+ */
++ (AdMobView *)requestAdWithDelegate:(id<AdMobDelegate>)delegate;
+
+/**
+ * Causes an existing AdMobView to display a fresh ad. If an ad successfully loads,
+ * it is animated in with a flip; if not, this call fails silently and the old
+ * ad remains onscreen.
+ *
+ * Note that, during the flip, views under the AdMobView will be exposed.
+ *
+ * If refreshing an ad, we recommend doing it no more frequently than every 12
+ * seconds. The click through rates of ads remain high for that amount of time
+ * and it gives users a chance to read and comprehend the ad.
+ */
+- (void)requestFreshAd;
+
+/**
+ * Returns the version of the current SDK.
+ */
++ (NSString *)version;
+
+/**
+ * This property is exposed so that the delegate can be cleared if it is going to
+ * be dealloc'ed. This ensures that the AdMob SDK will never make a call to a
+ * deallocated instance.
+ */
+@property (assign) id<AdMobDelegate> delegate;
+
+@end
View
90 BrainShot.xcodeproj/project.pbxproj
@@ -170,6 +170,8 @@
2F443A8311919DC50058609F /* libcocos2d libraries.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EE05E10304ED200A389B3 /* libcocos2d libraries.a */; };
2F443A8411919DC50058609F /* libsqlite3.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F7DEE12116397F1004E947B /* libsqlite3.0.dylib */; };
2F443A8511919DC50058609F /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F725768118876EF00B4FA3E /* StoreKit.framework */; };
+ 2F44A0CC119E9CE20071D347 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F44A0CB119E9CE20071D347 /* MediaPlayer.framework */; };
+ 2F44A0CE119E9CE20071D347 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F44A0CD119E9CE20071D347 /* MessageUI.framework */; };
2F620C36116E08D300177B9F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2F620C35116E08D300177B9F /* InfoPlist.strings */; };
2F620CBC116E200D00177B9F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 2F620CBB116E200D00177B9F /* Localizable.strings */; };
2F6DFD73116241200078600F /* Position.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F6DFD72116241200078600F /* Position.m */; };
@@ -196,6 +198,14 @@
2F7DEE4211639D21004E947B /* fail.png in Resources */ = {isa = PBXBuildFile; fileRef = 2F7DEE4011639D21004E947B /* fail.png */; };
2F7DEE4311639D21004E947B /* pass.png in Resources */ = {isa = PBXBuildFile; fileRef = 2F7DEE4111639D21004E947B /* pass.png */; };
2F7DEE5711639E6A004E947B /* ScoreLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F7DEE5611639E6A004E947B /* ScoreLayer.m */; };
+ 2F99A962119E9B30005F3A9E /* libAdMob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F99A95F119E9B30005F3A9E /* libAdMob.a */; };
+ 2F99A963119E9B30005F3A9E /* libAdMob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F99A95F119E9B30005F3A9E /* libAdMob.a */; };
+ 2F99A964119E9B30005F3A9E /* libAdMob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F99A95F119E9B30005F3A9E /* libAdMob.a */; };
+ 2F99A965119E9B30005F3A9E /* libAdMob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2F99A95F119E9B30005F3A9E /* libAdMob.a */; };
+ 2F99A968119E9B44005F3A9E /* AdMobLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F99A967119E9B44005F3A9E /* AdMobLayer.m */; };
+ 2F99A969119E9B44005F3A9E /* AdMobLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F99A967119E9B44005F3A9E /* AdMobLayer.m */; };
+ 2F99A96A119E9B44005F3A9E /* AdMobLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F99A967119E9B44005F3A9E /* AdMobLayer.m */; };
+ 2F99A96B119E9B44005F3A9E /* AdMobLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2F99A967119E9B44005F3A9E /* AdMobLayer.m */; };
2FA86840116CA06F009F3D8C /* SplashScene.m in Sources */ = {isa = PBXBuildFile; fileRef = 2FA8683F116CA06F009F3D8C /* SplashScene.m */; };
2FA8689D116CBE45009F3D8C /* DefaultRotate.png in Resources */ = {isa = PBXBuildFile; fileRef = 2FA8689C116CBE45009F3D8C /* DefaultRotate.png */; };
2FACE4D611673BE00062B492 /* BallLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2FACE4D511673BE00062B492 /* BallLayer.m */; };
@@ -453,6 +463,8 @@
2F3E75AE11998B4300F65F2D /* Info-universal.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-universal.plist"; sourceTree = "<group>"; };
2F3E7634119991F700F65F2D /* BrainShotFreex5.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BrainShotFreex5.app; sourceTree = BUILT_PRODUCTS_DIR; };
2F443A8A11919DC50058609F /* BrainShotFreex5.iphone.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BrainShotFreex5.iphone.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 2F44A0CB119E9CE20071D347 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
+ 2F44A0CD119E9CE20071D347 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; };
2F620C33116E08C800177B9F /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2F620C8E116E160500177B9F /* zh_CN */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = zh_CN; path = zh_CN.lproj/InfoPlist.strings; sourceTree = "<group>"; };
2F620CB9116E200700177B9F /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -512,6 +524,11 @@
2F7DEE5511639E6A004E947B /* ScoreLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScoreLayer.h; sourceTree = "<group>"; };
2F7DEE5611639E6A004E947B /* ScoreLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ScoreLayer.m; sourceTree = "<group>"; };
2F96597A1189BDD1008CE1E2 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
+ 2F99A95F119E9B30005F3A9E /* libAdMob.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libAdMob.a; sourceTree = "<group>"; };
+ 2F99A960119E9B30005F3A9E /* AdMobDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdMobDelegateProtocol.h; sourceTree = "<group>"; };
+ 2F99A961119E9B30005F3A9E /* AdMobView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdMobView.h; sourceTree = "<group>"; };
+ 2F99A966119E9B44005F3A9E /* AdMobLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdMobLayer.h; sourceTree = "<group>"; };
+ 2F99A967119E9B44005F3A9E /* AdMobLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdMobLayer.m; sourceTree = "<group>"; };
2FA8683E116CA06F009F3D8C /* SplashScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SplashScene.h; sourceTree = "<group>"; };
2FA8683F116CA06F009F3D8C /* SplashScene.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SplashScene.m; sourceTree = "<group>"; };
2FA8689C116CBE45009F3D8C /* DefaultRotate.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DefaultRotate.png; sourceTree = "<group>"; };
@@ -742,6 +759,9 @@
506EE1A91030508200A389B3 /* libcocos2d libraries.a in Frameworks */,
2F7DEE13116397F1004E947B /* libsqlite3.0.dylib in Frameworks */,
2F725769118876EF00B4FA3E /* StoreKit.framework in Frameworks */,
+ 2F99A965119E9B30005F3A9E /* libAdMob.a in Frameworks */,
+ 2F44A0CC119E9CE20071D347 /* MediaPlayer.framework in Frameworks */,
+ 2F44A0CE119E9CE20071D347 /* MessageUI.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -761,6 +781,7 @@
2F3E75A511998B4300F65F2D /* libcocos2d libraries.a in Frameworks */,
2F3E75A611998B4300F65F2D /* libsqlite3.0.dylib in Frameworks */,
2F3E75A711998B4300F65F2D /* StoreKit.framework in Frameworks */,
+ 2F99A963119E9B30005F3A9E /* libAdMob.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -780,6 +801,7 @@
2F3E762D119991F700F65F2D /* libcocos2d libraries.a in Frameworks */,
2F3E762E119991F700F65F2D /* libsqlite3.0.dylib in Frameworks */,
2F3E762F119991F700F65F2D /* StoreKit.framework in Frameworks */,
+ 2F99A962119E9B30005F3A9E /* libAdMob.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -799,6 +821,7 @@
2F443A8311919DC50058609F /* libcocos2d libraries.a in Frameworks */,
2F443A8411919DC50058609F /* libsqlite3.0.dylib in Frameworks */,
2F443A8511919DC50058609F /* StoreKit.framework in Frameworks */,
+ 2F99A964119E9B30005F3A9E /* libAdMob.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -871,6 +894,8 @@
2F7DEE12116397F1004E947B /* libsqlite3.0.dylib */,
2F725768118876EF00B4FA3E /* StoreKit.framework */,
2F96597A1189BDD1008CE1E2 /* StoreKit.framework */,
+ 2F44A0CB119E9CE20071D347 /* MediaPlayer.framework */,
+ 2F44A0CD119E9CE20071D347 /* MessageUI.framework */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -902,6 +927,8 @@
2FA8683F116CA06F009F3D8C /* SplashScene.m */,
2FB3DAD311871F530098ECD7 /* MyStoreObserver.h */,
2FB3DAD411871F530098ECD7 /* MyStoreObserver.m */,
+ 2F99A966119E9B44005F3A9E /* AdMobLayer.h */,
+ 2F99A967119E9B44005F3A9E /* AdMobLayer.m */,
);
path = Classes;
sourceTree = "<group>";
@@ -962,6 +989,16 @@
path = Models;
sourceTree = "<group>";
};
+ 2F99A95E119E9B30005F3A9E /* AdMob */ = {
+ isa = PBXGroup;
+ children = (
+ 2F99A95F119E9B30005F3A9E /* libAdMob.a */,
+ 2F99A960119E9B30005F3A9E /* AdMobDelegateProtocol.h */,
+ 2F99A961119E9B30005F3A9E /* AdMobView.h */,
+ );
+ name = AdMob;
+ sourceTree = "<group>";
+ };
502BC3541120837500A0B92A /* CocosDenshion */ = {
isa = PBXGroup;
children = (
@@ -995,6 +1032,7 @@
506EDAA3102F461B00A389B3 /* cocos2d Sources */ = {
isa = PBXGroup;
children = (
+ 2F99A95E119E9B30005F3A9E /* AdMob */,
50D3B00911498A370002F919 /* cocos2d */,
502BC3541120837500A0B92A /* CocosDenshion */,
504DFBC710AF12E9006D82FE /* cocoslive */,
@@ -1581,6 +1619,7 @@
2FCCB9F3116B7D3E0000CC6A /* MenuLayer.m in Sources */,
2FA86840116CA06F009F3D8C /* SplashScene.m in Sources */,
2FB3DAD511871F530098ECD7 /* MyStoreObserver.m in Sources */,
+ 2F99A96B119E9B44005F3A9E /* AdMobLayer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1617,6 +1656,7 @@
2F3E759811998B4300F65F2D /* MenuLayer.m in Sources */,
2F3E759911998B4300F65F2D /* SplashScene.m in Sources */,
2F3E759A11998B4300F65F2D /* MyStoreObserver.m in Sources */,
+ 2F99A969119E9B44005F3A9E /* AdMobLayer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1653,6 +1693,7 @@
2F3E7620119991F700F65F2D /* MenuLayer.m in Sources */,
2F3E7621119991F700F65F2D /* SplashScene.m in Sources */,
2F3E7622119991F700F65F2D /* MyStoreObserver.m in Sources */,
+ 2F99A968119E9B44005F3A9E /* AdMobLayer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1689,6 +1730,7 @@
2F443A7611919DC50058609F /* MenuLayer.m in Sources */,
2F443A7711919DC50058609F /* SplashScene.m in Sources */,
2F443A7811919DC50058609F /* MyStoreObserver.m in Sources */,
+ 2F99A96A119E9B44005F3A9E /* AdMobLayer.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1858,6 +1900,10 @@
GCC_THUMB_SUPPORT = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = Resources/Info.plist;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
@@ -1884,6 +1930,10 @@
GCC_THUMB_SUPPORT = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = Resources/Info.plist;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
@@ -1927,6 +1977,10 @@
GCC_THUMB_SUPPORT = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = Resources/Info.plist;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
@@ -1972,6 +2026,10 @@
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = "Resources/Info-universal.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
@@ -1999,6 +2057,10 @@
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = "Resources/Info-universal.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
@@ -2026,6 +2088,10 @@
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = "Resources/Info-universal.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_LDFLAGS = (
"-all_load",
"-ObjC",
@@ -2057,6 +2123,10 @@
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = "Resources/Info-universal.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_CFLAGS = (
"-DDEBUG=1",
"-DFREE=1",
@@ -2088,6 +2158,10 @@
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = "Resources/Info-universal.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_CFLAGS = "-DFREE=1";
OTHER_LDFLAGS = (
"-all_load",
@@ -2116,6 +2190,10 @@
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = "Resources/Info-universal.plist";
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_CFLAGS = "-DFREE=1";
OTHER_LDFLAGS = (
"-all_load",
@@ -2147,6 +2225,10 @@
GCC_THUMB_SUPPORT = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = Resources/Info.plist;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_CFLAGS = (
"-DDEBUG=1",
"-DFREE=1",
@@ -2178,6 +2260,10 @@
GCC_THUMB_SUPPORT = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = Resources/Info.plist;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_CFLAGS = "-DFREE=1";
OTHER_LDFLAGS = (
"-all_load",
@@ -2206,6 +2292,10 @@
GCC_THUMB_SUPPORT = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
INFOPLIST_FILE = Resources/Info.plist;
+ LIBRARY_SEARCH_PATHS = (
+ "$(inherited)",
+ "\"$(SRCROOT)\"",
+ );
OTHER_CFLAGS = "-DFREE=1";
OTHER_LDFLAGS = (
"-all_load",
View
21 Classes/AdMobLayer.h
@@ -0,0 +1,21 @@
+//
+// AdMob.h
+// EyeRelax
+//
+// Created by saberma on 10-5-15.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "cocos2d.h"
+#import "AdMobView.h"
+#import "AdMobDelegateProtocol.h"
+#define AD_REFRESH_PERIOD 60.0 // display fresh ads once per minute
+
+
+@interface AdMobLayer : CCLayer <AdMobDelegate> {
+ AdMobView *adMobAd;
+ NSTimer *refreshTimer; // timer to get fresh ads
+}
+
+@end
View
69 Classes/AdMobLayer.m
@@ -0,0 +1,69 @@
+//
+// AdMob.m
+// EyeRelax
+//
+// Created by saberma on 10-5-15.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import "AdMobLayer.h"
+
+
+@implementation AdMobLayer
+
+- (void)didReceiveAd:(AdMobView *)adView {
+
+ // put the ad at the top middle of the screen in landscape mode
+ //adMobAd.frame = CGRectMake(0, 432, 320, 48);
+ adMobAd.frame = CGRectMake(0, 432, 320, 48);
+ CGAffineTransform makeLandscape = CGAffineTransformMakeRotation(M_PI * 0.5f);
+ makeLandscape = CGAffineTransformTranslate(makeLandscape, -216, -134);//centers the ad in landscape mode
+ adMobAd.transform = makeLandscape;
+ [[[CCDirector sharedDirector] openGLView] addSubview:adMobAd];
+ [refreshTimer invalidate];
+ refreshTimer = [NSTimer scheduledTimerWithTimeInterval:AD_REFRESH_PERIOD target:self selector:@selector(refreshAd:) userInfo:nil repeats:YES];
+}
+
+- (void)onEnter {
+ adMobAd = [AdMobView requestAdWithDelegate:self];
+ [adMobAd retain];
+ [super onEnter];
+}
+
+- (void)onExit {
+ [adMobAd removeFromSuperview];
+ [adMobAd release];
+ [super onExit];
+}
+
+// Request a new ad. If a new ad is successfully loaded, it will be animated into location.
+- (void)refreshAd:(NSTimer *)timer {
+ [adMobAd requestFreshAd];
+}
+
+// AdMobDelegate methods
+
+- (NSString *)publisherId {
+ return @"a14be1829817892"; // this is your publisher ID
+}
+
+- (UIColor *)adBackgroundColor {
+ return [UIColor colorWithRed:0.4 green:0.6 blue:0.2 alpha:1]; // this should be prefilled; if not, provide a UIColor
+}
+
+- (UIColor *)primaryTextColor {
+ return [UIColor whiteColor]; // this should be prefilled; if not, provide a UIColor
+}
+
+- (UIColor *)secondaryTextColor {
+ return [UIColor colorWithRed:0.4 green:0.6 blue:0.2 alpha:1]; // this should be prefilled; if not, provide a UIColor
+}
+
+- (BOOL)mayAskForLocation {
+ return NO; // this should be prefilled; if not, see AdMobProtocolDelegate.h for instructions
+}
+
+- (UIViewController *)currentViewController {
+ return nil;
+}
+@end
View
BIN libAdMob.a
Binary file not shown.
View
BIN logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 49a8bf4

Please sign in to comment.