简体   繁体   中英

The firebase admob banner advertisement is displayed in the upper left. How can I display it at the bottom center of the screen?

I would like to display AdMob's banner advertisement on the bottom of the screen using firebase. Currently, the banner advertisement will be displayed on the screen Left-Top. I found the following classes and values that are likely to be related from the framework, but I do not know how to use it. Even if I looked at Document and sample I could not get usage.

firebase :: admob :: BannerView :: Position firebase :: admob :: BannerView :: kPositionBottom

Please tell me how to display the banner ad on the bottom of the screen.

Development environment Xcode 9.1 cocos2d-x 3.16 firebase 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);
        }
    }
}]

Screenshot

It doesn't look like you're calling moveTo , which is the BannerView method that changes the banner's position. There's a version that takes the constant you mentioned (kPositionBottom), and a version that takes an (x,y) pair.

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