1
我想使用Firebase在屏幕底部显示AdMob的横幅广告。 目前,横幅广告将显示在屏幕左上方。 我发现以下可能与框架相关的类和值,但我不知道如何使用它。即使我看着Document和sample我也无法使用。Firebase宣传横幅广告显示在左上角。我怎样才能在屏幕的底部中心显示它?
火力:: AdMob广告:: BannerView ::位置 火力:: AdMob广告:: BannerView :: kPositionBottom
请告诉我如何在屏幕底部显示横幅广告。
开发环境Xcode的 9.1 的cocos2d-x 3.16 火力CPP SDK 4.2.0
[bool HelloWorld::init(){
if (!Layer::init())
{
return false;
}
// Intitialize Firebase AdMob.
firebase::admob::Initialize(*firebase::App::GetInstance(), kAdMobAppID);
firebase::admob::BannerView* banner_view = new firebase::admob::BannerView();
firebase::admob::AdSize ad_size;
ad_size.ad_size_type = firebase::admob::kAdSizeStandard;
ad_size.width = 320;
ad_size.height = 50;
banner_view->Initialize(getAdParent(), kAdViewAdUnit, ad_size);
this->scheduleUpdate();
return true;
}
void HelloWorld::update(float delta)
{
// Check that the banner has been initialized.
if (banner_view->InitializeLastResult().status() ==firebase::kFutureStatusComplete)
{
// Check that the banner hasn't started loading.
if (banner_view->LoadAdLastResult().status() == firebase::kFutureStatusInvalid)
{
// Make the banner visible and load an ad.
CCLOG("Loading a banner.");
banner_view->Show();
firebase::admob::AdRequest my_ad_request = {};
banner_view->LoadAd(my_ad_request);
}
}
}]
谢谢! 它能够显示在底部! – poco