我应该留出多少空间来获得底层Admob横幅?

时间:2016-07-07 13:39:10

标签: c++ cocos2d-iphone cocos2d-x cocos2d-x-3.0 cocos2d-android

我在屏幕底部遗漏了大约100个(不知道单位)adob横幅,这将在项目结束时添加。

对于iphone 6,admob横幅的高度约为100。

但是,当我搬到ipad时,这个高度是不同的。

所以有些元素的位置不同(高度方向)。

例如:

float admobHeight = 100.0;

Vec2 desiredPosition = Vec2(0, 100);

auto sprite = Sprite::create("image.png");
sprite->setAnchorPoint(Vec2(0, 0));

// Leave out space for the bottom Admob banner.
sprite->setPosition(Vec2(desiredPosition.x, desiredPosition.y + admobHeight));

this->addChild(sprite);

我将DesignResolution设置为:

(AppDelegate.cpp)

static cocos2d::Size designResolutionSize = cocos2d::Size(768, 1136);

和解决方案政策NO_BORDER:

glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);

对于每种类型的设备,如何在屏幕底部为Admob留出适当数量的空间?

1 个答案:

答案 0 :(得分:0)

标准横幅高度为60px 这是admob banner integration的代码

bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0,viewController.view.frame.size.height-60,viewController.view.frame.size.width,60)];         bannerView_.center = CGPointMake(viewController.view.frame.size.width / 2.f,viewController.view.frame.size.height-30);         bannerView_.adUnitID = ADMOB_BANNER_ID;

    bannerView_.rootViewController=self.viewController;

    //[UIViewController:addSubview:bannerView_];
    [viewController.view addSubview:bannerView_];
    // Initiate a generic request to load it with an ad.
    [bannerView_ loadRequest:[GADRequest request]];