updaed for iOS6

This commit is contained in:
Michael Nguyen
2013-10-28 15:20:35 -07:00
parent 4eb1fd35e0
commit 84ca7457b5
86 changed files with 304 additions and 14535 deletions

View File

@@ -12,7 +12,6 @@
#include "GameApp.h"
#import "AdWhirlView.h"
#import "wagicAppDelegate.h"
@@ -67,15 +66,10 @@ void DestroyGame(void)
}
#pragma mark Ad management constants
static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPHONE = @"b86aba511597401ca6b41c1626aa3013";
static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170c8d268f";
#pragma mark -
@implementation EAGLView
@synthesize adView;
@synthesize animating;
@dynamic animationFrameInterval;
@synthesize currentLocation;
@@ -91,7 +85,6 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
- (void)dealloc
{
[renderer release];
[self removeAds];
[super dealloc];
}
@@ -635,30 +628,6 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
}
//These are the methods for the AdWhirl Delegate, you have to implement them
#pragma mark AdWhirlDelegate methods
- (void)adWhirlWillPresentFullScreenModal {
//It's recommended to invoke whatever you're using as a "Pause Menu" so your
//game won't keep running while the user is "playing" with the Ad (for example, iAds)
[self pauseGame];
}
- (void)adWhirlDidDismissFullScreenModal {
//Once the user closes the Ad he'll want to return to the game and continue where
//he left it
[self resumeGame];
}
- (NSString *)adWhirlApplicationKey {
if ((UI_USER_INTERFACE_IDIOM()) == UIUserInterfaceIdiomPad)
return _MY_AD_WHIRL_APPLICATION_KEY_IPAD;
return _MY_AD_WHIRL_APPLICATION_KEY_IPHONE;
}
- (UIViewController *)viewControllerForPresentingModalView {
//Remember that UIViewController we created in the Game.h file? AdMob will use it.
//If you want to use "return self;" instead, AdMob will cancel the Ad requests.
@@ -666,101 +635,5 @@ static NSString *_MY_AD_WHIRL_APPLICATION_KEY_IPAD = @"2e70e3f3da40408588b9a3170
}
- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlView {
[UIView beginAnimations:@"AdWhirlDelegate.adWhirlDidReceiveAd:"
context:nil];
BOOL isLandscape = UIDeviceOrientationIsLandscape( [UIDevice currentDevice].orientation);
[UIView setAnimationDuration:0.7];
CGSize adSize = [adWhirlView actualAdSize];
CGRect newFrame = [adWhirlView frame];
CGSize screenSize = [self.window bounds].size;
newFrame.size = adSize;
// ads are 320 x 50
newFrame.origin.x = ( (isLandscape ? screenSize.height : screenSize.width) - adSize.width)/ 2;
newFrame.origin.y = ( (isLandscape ? screenSize.width : screenSize.height) - 50);
[adWhirlView setFrame: newFrame];
[UIView commitAnimations];
}
-(void)adWhirlDidFailToReceiveAd:(AdWhirlView *)adWhirlView usingBackup:(BOOL)yesOrNo {
//The code to show my own Ad banner again
NSLog(@"failed to get an Ad");
}
-(void) removeAds {
//There's something weird about AdWhirl because setting the adView delegate
//to "nil" doesn't stops the Ad requests and also it doesn't remove the adView
//from superView; do the following to remove AdWhirl from your scene.
//
//If adView exists, remove everything
if (adView) {
//Remove adView from superView
[adView removeFromSuperview];
//Replace adView's view with "nil"
[adView replaceBannerViewWith:nil];
//Tell AdWhirl to stop requesting Ads
[adView ignoreNewAdRequests];
//Set adView delegate to "nil"
[adView setDelegate:nil];
//Release adView
[adView release];
//set adView to "nil"
adView = nil;
}
}
-(void) displayAds
{
BOOL isLandscape = UIDeviceOrientationIsLandscape( [UIDevice currentDevice].orientation);
//Assign the AdWhirl Delegate to our adView
if ( adView != nil )
[self removeAds];
//Let's allocate the viewController (it's the same RootViewController as declared
//in our AppDelegate; will be used for the Ads)
viewController = [(wagicAppDelegate *)[[UIApplication sharedApplication] delegate] glViewController];
self.adView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
//Set auto-resizing mask
self.adView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
//This isn't really needed but also it makes no harm. It just retrieves the configuration
//from adwhirl.com so it knows what Ad networks to use
[adView updateAdWhirlConfig];
//Get the actual size for the requested Ad
CGSize adSize = [adView actualAdSize];
//
//Set the position; remember that we are using 4 values (in this order): X, Y, Width, Height
//You can comment this line if your game is in portrait mode and you want your Ad on the top
//if you want the Ad in other position (portrait or landscape), use the following code,
//for this example, the Ad will be positioned in the bottom+center of the screen
//(in landscape mode):
//Same explanation as the one in the method "adjustAdSize" for the Ad's width
int screenWidth = [viewController.parentViewController.view bounds].size.width;
float yOffset = [viewController.parentViewController.view bounds].size.height - adSize.height;
if ( isLandscape )
{
screenWidth = [viewController.parentViewController.view bounds].size.height;
yOffset = screenWidth - adSize.height;
}
self.adView.frame = CGRectMake((screenWidth - adSize.width) / 2, yOffset, adSize.width, adSize.height);
//Trying to keep everything inside the Ad bounds
self.adView.clipsToBounds = YES;
//Adding the adView (used for our Ads) to our viewController
[viewController.view addSubview:adView];
//Bring our view to front
[viewController.view bringSubviewToFront:adView];
}
@end