简体   繁体   中英

has anyone integrated tapjoy into cocos2d app/game?

is anyone here has integrated tapjoy with cocos2d? if so, I want to ask about _mainCtrl in tapjoy sample project..

what should I change that? (since my cocos2d project doesn't have UIViewController ....)

thx all.

Cocos2d comes with a view controller. Look for RootViewController.h in your project.

In AppDelegate.mm

 #import "TapjoyConnect.h"
 #define TAPJOY_APP_ID               @"c9a2551a-305d-47fd-a95b-b4d66e9a4ee6"
 #define TAPJOY_APP_SECRECT_KEY      @"5WbspdtRedZ8oAgmJOIS"

//note that these are ID provided by SDK. test ID. for this always ads are displayed. //For your id, ads are displayed only after app released.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   ...
   ...

       [TapjoyConnect requestTapjoyConnect:TAPJOY_APP_ID secretKey:TAPJOY_APP_SECRECT_KEY];

       [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getFullScreenAd:) name:TJC_FULL_SCREEN_AD_RESPONSE_NOTIFICATION object:nil];

       [self showTapJoyAds];
      return YES;
}

- (void)getFullScreenAd:(NSNotification*)notifyObj
{
    [TapjoyConnect showFullScreenAd];
}


//call this in place where you want to show ads..
-(void)showTapJoyAds
{
   [TapjoyConnect getFullScreenAd];
}

This works for me in cocos2d v2.1:

To show the TapJoy offerwall in your cocos2d game, first import the following:

#import "AppDelegate.h" //fixes 'Appcontrol' problem
#import <Tapjoy/Tapjoy.h>

Use this code to make the tapjoy offerwall appear:

//get rootviewcontroller
AppController *app= (AppController*) [[UIApplication sharedApplication] delegate];
UIViewController *rootViewController=[app navController];

//Show offerwall
[TapjoyConnect showOffersWithViewController:rootViewController];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM