J
JDSTIGER
Guest
I'm an idiot, how do I make it so my banner by AdMob is centered at the bottom of the screen no matter what the display size is..?
Social event:
var ident = ds_map_find_value(async_load, 'type');
var loaded = ds_map_find_value(async_load, 'loaded');
if(ident == 'banner_load')
{
if(loaded)
{
banner_w = ds_map_find_value(async_load, 'width');
banner_h = ds_map_find_value(async_load, 'height');
banner_x = (display_get_width() - banner_w) / 2; // the horizontal center of the page
banner_y = (display_get_height() - banner_h); // at the bottom of the page
GoogleMobileAds_MoveBanner(banner_x, banner_y);
}
}
Its on the top left corner still :/Maybe:
Code:Social event: var ident = ds_map_find_value(async_load, 'type'); var loaded = ds_map_find_value(async_load, 'loaded'); if(ident == 'banner_load') { if(loaded) { banner_w = ds_map_find_value(async_load, 'width'); banner_h = ds_map_find_value(async_load, 'height'); banner_x = (display_get_width() - banner_w) / 2; // the horizontal center of the page banner_y = (display_get_height() - banner_h); // at the bottom of the page GoogleMobileAds_MoveBanner(banner_x, banner_y); } }
Maybe:
Code:banner_x = (display_get_width() - banner_w) / 2; // the horizontal center of the page banner_y = (display_get_height() - banner_h); // at the bottom of the page GoogleMobileAds_MoveBanner(banner_x, banner_y);
hmm. What ifCan you help me how can I add the banner at the top instead of bottom? I've tried banner_y = (display_get_height() - banner_h)*2, *4, *6, *8 and it works but not for every phone.
I took a snippet of the code, he works well.
Show your code then. Is not there accidentally overwriting the coordinates?
Banner you create 1 time?
GoogleMobileAds_UseTestAds(true, "**********");
global.bannerId = "ca-app-pub-******";
GoogleMobileAds_Init(global.bannerId);
GoogleMobileAds_AddBanner(global.bannerId, GoogleMobileAds_Banner);
GoogleMobileAds_Init("ca-app-pub-****/*****"); // application ID (!)
banner_id = "ca-app-pub-****/+++++"; // Ad banner ID (!)
GoogleMobileAds_AddBanner(banner_id, GoogleMobileAds_Banner);
GoogleMobileAds_MoveBanner(0, 0); // move banner to the zero position (for example).
Works like a charm! So simple! I cannot believe I didn't see this.hmm. What if
banner_y = 0;
You're welcome!Works like a charm! So simple! I cannot believe I didn't see this.
Thank you so MUCH for this help!
I am doing exactly what you're saying It didnt work, I must be cursed or something wtfThe code run 1 time in Create.
Next, after receiving an asynchronous response, the banner will be moved to the right place (on position banner_x, banner_y).Code:GoogleMobileAds_Init("ca-app-pub-****/*****"); // application ID (!) banner_id = "ca-app-pub-****/+++++"; // Ad banner ID (!) GoogleMobileAds_AddBanner(banner_id, GoogleMobileAds_Banner); GoogleMobileAds_MoveBanner(0, 0); // move banner to the zero position (for example).
How did it work for you and not me !?!?!?!?!?!?Works like a charm! So simple! I cannot believe I didn't see this.
Thank you so MUCH for this help!
This is strange.I am doing exactly what you're saying It didnt work, I must be cursed or something wtf
Actually I'm not using ds_ events and assync.I am doing exactly what you're saying It didnt work, I must be cursed or something wtf
How did it work for you and not me !?!?!?!?!?!?
This is strange.
And what version of GMS, module GooplePlayService?
Make a test .gmx and available for download, I'll look at the code.
THANKS TO BOTH I FINALLY FIXED IT, The problem was the banner wasn't persistent.Are you changing rooms?
Try putting the obj_ad in all of the rooms.
I seem to have a bug sometimes that the ad does not move to a new position even if the object is persistent when the player quickly switches to a new room.