2014-10-06 23:42:18.066 myapp[10324:300607] <Google> To get test ads on this device, call: request.testDevices = @[ GAD_SIMULATOR_ID ];
2014-10-06 23:42:18.197 my app[10324:300607] we
2014-10-06 23:42:21.368 my app[10324:300607] Received ad successfully
2014-10-06 23:42:21.370 my app[10324:300607] SDK version: afma-sdk-i-v6.12.0
-----------------------------------------------------------------------------------
Sample app
-----------------------------------------------
(void) adMobSetup
{
CGPoint origin = CGPointMake(0.0,
self.view.frame.size.width -
CGSizeFromGADAdSize(kGADAdSizeSmartBannerLandscape).height);
// Use predefined GADAdSize constants to define the GADBannerView.
self.adBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerLandscape origin:origin];
self.adBanner.adUnitID = k_adMob_ID;
self.adBanner.delegate = self;
self.adBanner.rootViewController = self;
[self.view addSubview:self.adBanner];
[self.adBanner loadRequest:[self request]];
}
- (GADRequest *)request {
GADRequest *request = [GADRequest request];
// Make the request for a test ad. Put in an identifier for the simulator as well as any devices
// you want to receive test ads.
// comment this line when you add your sign and want to upload on the appstore
request.testDevices = @[ GAD_SIMULATOR_ID ];
return request;
}
- (void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(@"Received ad successfully");
NSLog(@"SDK version: %@", [GADRequest sdkVersion]);}
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]);
}
------------------------------------
#import "GameViewController.h"
#import <QuartzCore/CADisplayLink.h>
#import "defined.h"
SystemSoundID soundID;
@interface GameViewController ()
@property ( nonatomic , assign) float rot;
@property ( nonatomic , assign) float speeder;
@property ( nonatomic , assign) int gameScore;
@property ( nonatomic , assign) float speed;
@property ( nonatomic , assign) float vx;
@property ( nonatomic , assign) float vy;
@property ( nonatomic , assign) float friction;
@property ( nonatomic , assign) int maxspeed;
@property ( nonatomic , assign) bool leftNow;
@property ( nonatomic , assign) bool rightNow;
@property ( nonatomic , assign) int whatIsNowLevel;
@property ( nonatomic , assign) int rotationTime;
@property ( nonatomic , assign) int harderNow;
@property ( nonatomic , strong ) AVAudioPlayer * gameOverSound;
@property ( nonatomic , strong ) AVAudioPlayer * smallLaugh;
@property ( nonatomic , strong ) AVAudioPlayer * longLaugh;
@property ( nonatomic , strong ) AVAudioPlayer * pop;
@property ( nonatomic , assign) float flipFlopValue;
@property ( nonatomic , assign) float flipFlopRotation;
@property ( nonatomic , assign) float flipFlopTemp;
@property ( nonatomic , assign) float viewRot;
@property ( nonatomic , strong ) NSTimer *timer;
@property ( nonatomic , assign ) int tempTime;
@property ( nonatomic , assign ) int protectedTimer;
@property ( nonatomic , assign ) int protectedTimerTemp;
@property ( nonatomic , assign ) bool protectedTimerCheck;
@property ( nonatomic , assign ) bool Thunder;
@property ( nonatomic , assign ) int lowSpeedTimer;
@property ( nonatomic , assign ) int QueckTime;
@property ( nonatomic , assign ) int QuackeCounter;
@property ( nonatomic , assign ) int protectedActice;
@property ( nonatomic , assign ) int angleTimer;
@property ( nonatomic , assign ) float limitedScreen;
@property ( nonatomic , assign ) float angleMulti;
@property ( nonatomic , assign ) int LightNoLight;
@property ( nonatomic , assign ) bool isGameCenterAvailable;
@property ( nonatomic , strong ) id displayLink;
@end
@implementation GameViewController
@synthesize Bg;
@synthesize raspberry;
@synthesize bird;
@synthesize backDay;
@synthesize scoreLbl;
@synthesize pineapple;
@synthesize timercounter;
@synthesize gameObject;
@synthesize protecteed;
@synthesize apple;
@synthesize watermelon;
@synthesize pauseView;
@synthesize specialF1;
@synthesize sf;
@synthesize sf2;
@synthesize rot;
@synthesize speeder;
@synthesize gameScore;
@synthesize speed;
@synthesize vx;
@synthesize vy;
@synthesize friction;
@synthesize maxspeed;
@synthesize leftNow , rightNow;
@synthesize whatIsNowLevel;
@synthesize rotationTime;
@synthesize harderNow;
@synthesize flipFlopRotation;
@synthesize flipFlopTemp;
@synthesize flipFlopValue;
@synthesize viewRot;
@synthesize timer;
@synthesize tempTime;
@synthesize protectedTimer;
@synthesize lowSpeedTimer;
@synthesize QueckTime;
@synthesize QuackeCounter;
@synthesize protectedActice;
@synthesize protectedTimerCheck;
@synthesize protectedTimerTemp;
@synthesize Thunder;
@synthesize limitedScreen;
@synthesize LightNoLight;
@synthesize theaudio;
@synthesize angleTimer;
@synthesize angleMulti;
@synthesize isGameCenterAvailable;
@synthesize displayLink;
@synthesize smallLaugh,longLaugh,pop,gameOverSound;
bool soundForOver;
bool soundForFruit;
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appHasGoneInBackground)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appHasGoneInBackground)
name:UIApplicationWillResignActiveNotification
object:nil];
[self initals];
[self SoundsSystems];
[self adMobSetup];
displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(loop)];
[displayLink setFrameInterval:1];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
// Do any additional setup after loading the view.
}
- (void) adMobSetup
{
CGPoint origin = CGPointMake(0.0,
self.view.frame.size.width -
CGSizeFromGADAdSize(kGADAdSizeSmartBannerLandscape).height);
// Use predefined GADAdSize constants to define the GADBannerView.
self.adBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerLandscape origin:origin];
self.adBanner.adUnitID = k_adMob_ID;
self.adBanner.delegate = self;
self.adBanner.rootViewController = self;
[self.view addSubview:self.adBanner];
[self.adBanner loadRequest:[self request]];
}
- (GADRequest *)request {
GADRequest *request = [GADRequest request];
// Make the request for a test ad. Put in an identifier for the simulator as well as any devices
// you want to receive test ads.
// comment this line when you add your sign and want to upload on the appstore
request.testDevices = @[ GAD_SIMULATOR_ID ];
return request;
}
- (void)adViewDidReceiveAd:(GADBannerView *)adView {
NSLog(@"Received ad successfully");
NSLog(@"SDK version: %@", [GADRequest sdkVersion]);}
- (void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error {
NSLog(@"Failed to receive ad with error: %@", [error localizedFailureReason]);
}
- (void ) appHasGoneInBackground
{
[self pauseAction:nil];
}
Sample code , gameviewcontroller.m
...
@property ( nonatomic <spa
#import "UIView+Hierarchy.h"
@implementation UIView(Hierarchy)
-(int)getSubviewIndex
{
return [self.superview.subviews indexOfObject:self];}
-(void)bringToFront
{
[self.superview bringSubviewToFront:self];
}
-(void)sendToBack
{
[self.superview sendSubviewToBack:self];
}
-(void)bringOneLevelUp
{
int currentIndex = [self getSubviewIndex];
[self.superview exchangeSubviewAtIndex:currentIndex withSubviewAtIndex:currentIndex+1];
}
-(void)sendOneLevelDown
{
int currentIndex = [self getSubviewIndex];
[self.superview exchangeSubviewAtIndex:currentIndex withSubviewAtIndex:currentIndex-1];
}
-(BOOL)isInFront
{
return ([self.superview.subviews lastObject]==self);
}
-(BOOL)isAtBack
{
return ([self.superview.subviews objectAtIndex:0]==self);
}
-(void)swapDepthsWithView:(UIView*)swapView
{
[self.superview exchangeSubviewAtIndex:[self getSubviewIndex] withSubviewAtIndex:[swapView getSubviewIndex]];
}
-(NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
@end
CGPoint origin;
if( self.view.frame.size.height < self.view.frame.size.width){
origin = CGPointMake(0.0,
self.view.frame.size.height -
CGSizeFromGADAdSize(
kGADAdSizeSmartBannerLandscape).height);
}else{
origin = CGPointMake(0.0,
self.view.frame.size.width -
CGSizeFromGADAdSize(
kGADAdSizeSmartBannerLandscape).height - self.navigationController.navigationBar.frame.size.height);
}
self.gAdBannerView = [[GADBannerView alloc]
initWithAdSize:kGADAdSizeSmartBannerLandscape
origin:origin];
...