Question

I am developing a game in cocos2d-x as it seemed the best option for me. Although I am in early stages of development, i was doing some research and was thinking about using Revmob ad network. I didn't find any help anywhere, asked at the cocos2d-x forums but didn't get any response. Has anyone implemented revmob in their apps or rather cocos2d-x games?

http://sdk.revmob.com/ A quick link to their sdk.

They have support for iphone, android but I don't know if I can make them work with cocos2d-x or android NDK. Any help would be greatly appreciated.

Thanks alot for reading it out.

Was it helpful?

Solution

Almost all of the Ads library providers only provide Native Code (Android/iOS). To do this in Cocos2dX you need to Write a C++ Wrapper on the top of the Revmob API.

someone has done it for Flurry which will give you some hint how to accomplish this

https://github.com/diwu/AnalyticX

One more guy has written complete story how did he accomplished this kind of thing. See Below

http://blog.molioapp.com/2011/11/openfeint-and-admob-integrated-with.html

Just to get you going below is something you at least need to know/do. In short make a delegate to get the call backs. Make a singelton @interface for ObjectiveC and also one for Java. However for java you also need to make a JNI class. Note that I wrote Singleton because in 90% cases we need to show only 1 ad and it resides on the top of the screen.

See below classes you need to make if you start from scratch. As I know Objective-C so I would only tel this part. For details you can explore the above threads.

  1. ReveMobCWrapperDelegate.h to make pure virtual methods i.e

    virtual void didAddSuccss() = 0;
    virtual void didAddFailed() = 0;
    
  2. RevMobCWrapper.h to make it usable from Android/iOS. In best case it should be a single file for iOS and Android. For intstance consider method void showAdd(ccPoint pos);

  3. RevmobCBinding.h will be @interface of Objective C, however it will contains the delegate variable of (1) RevMobCWrapperDelegate.h to throw the call back once Add is received. For ease make it singelton. Note that this implementation would be mixture of C and Objective C and will be using methods of Revmob API also be careful to give the C++ and Objective C implementation you need to make this extension ".mm" like RevmobCBiniding.mm.

  4. For writing the implementation of RevMobCWrapper either you can use RevmobCBinding.mm or make one new file namely RevMobCWrapper.mm

OTHER TIPS

RevMob now have an SDK for Cocos2d-x: http://sdk.revmob.com/cocos2dx.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top