Hi everyone!
I added RevMob ads to my Android game today and now I am adding it to iOS version (this tutorial: http://sdk.revmobmobileadnetwork.com/ios.html).
It works well but I want to manually tell when to show/hide ads.
What I did was added method showAds() to CCApplication.cpp and CCApplication.mm classes.
I managed it on Android, but I don’t know how to do it on iOS.
My RevMob banner is in AppController.mm class:
void CCApplication::showAds(bool pszUrl)
{
//here i wanna to execute show() method
}
I don’t know ObjectiveC but I suppose it is very easy to do
In Java I did it with abstract method added to Cocos2dxActivity.java and implemented in MyGame.java
How can I execute show() method from CCApplication.mm?
Or is there any other solution to show/hide RevMob banner on iOS platform game?
Thanks in advance!
Best regards!
Thank you very much for your reply.
I don’t need to call showAds() from AppController.mm but I need to call AppController’s (void)show method from CCApplication.mm.
Thanks!
That works because your show method is static (the + indicate a static method in Objective-C).
For non-static methods, you need to acquire an instance of the object. The easiest way to do that is to use a singleton, for example:
[[AppController sharedController] show];
Please note: to do that, your file needs to be a .mm (.m or .cpp won’t work), and it’s iOS specific, so it’s best if you put the file in an iOS specific location.
The prefered way to do wrappers (because that’s what it is) is to have the .h shared between all platforms, and a .cpp (Android) or .mm (iOS) specific to the platform, which implements the .h methods.