W aplikacji demonstrującej rozszerzenie "GoogleMobileAdsExt" moje reklamy się zawsze wyświetlają (i są to moje reklamy, bo jak wpiszę dowolne znaki jako identyfikator i wtedy uruchomię to się nie wyświetlają). Póki co testuje to na emulatorze i internet jest. Może pokaże jeden z przykładów jak próbowałem robić, a ktoś mi podpowie na podstawie tego dlaczego nie działa.
Metoda kopiowania kodu z dema:
Kod który wklejam do objInitAds->create dodatkowego rooma inicjującego, który jest odpalany tylko raz
GML
//Kod z objControl->create
///Initialise
GoogleMobileAds_Init("ca-app-pub-xxxxxxxxx"); //id pelnoekranowej
global.bannerId = "ca-app-pub-xxxxxxxxx"; //id banera
global.useTestAds = false; // Note that before using the button for this you must have added your device ID into objToggleTest
global.bottomRight = false;
global.interLoading = false;
//kod z objLoadIntersitial->Left Released
event_inherited();
GoogleMobileAds_LoadInterstitial();
global.interLoading = true;
//poza reklamami
globalvar games;
games=0;
room=menu;
Kod który wklejam do objAds->create który dodaje do każdego rooma
GML
//kod z objAddBanner->create
///Add a banner at bottom right of screen
event_inherited();
// Call our ad
show_debug_message("Add banner");
global.bottomRight = true;
GoogleMobileAds_AddBanner(global.bannerId, GoogleMobileAds_Banner);
// Position it at bottom right of screen
var bw = GoogleMobileAds_BannerGetWidth();
var bh = GoogleMobileAds_BannerGetHeight();
var px = display_get_width()-bw;
var py = display_get_height()-bh;
GoogleMobileAds_MoveBanner(px, py);
show_debug_message("Moving banner: " + string(px) + "," + string(py));
Kod który wklejam do objAds->Asynchronous->Social
GML
//Kod z objControl->Social
///Get banner info and reposition it if we wish
show_debug_message("Social async event...");
var ident = string(ds_map_find_value(async_load, "type" ));
var loaded = ds_map_find_value(async_load, "loaded");
if (ident == "banner_load")
{
if (loaded)
{
var bw = ds_map_find_value(async_load, "width");
var bh = ds_map_find_value(async_load, "height");
show_debug_message("Banner loaded: size=" + string(bw) + "," + string(bh) );
// Centre the ad on the screen (override what's in the AddBanner button code)
//var px = (display_get_width() - bw)/2;
//var py = (display_get_height() - bh)/2;
//GoogleMobileAds_MoveBanner(px, py);
//show_debug_message("Banner moved via Social event to " + string(px) + "," + string(py) );
/*
The commented-out lines above are what we would have to do for some other ad providers if
we wanted to load a banner at a specified location. The code is here for Google also just
to demonstrate how you can still use the event to control positioning ads with this provider.
*/
}
else { show_debug_message("Banner failed to load!"); }
}
else if (ident == "interstitial_load")
{
global.interLoading = false;
if(loaded) { show_debug_message("Interstitial loaded"); }
else { show_debug_message("Interstitial failed to load!"); }
}
Kod funkcji wyświetlającej reklamy to tylko alarm który sprawdza czy reklama jest "Ready" - jeżeli tak to wywołuje funkcje, jeżeli nie to znów ustawia alarm na pół sekundy, ale to jeszcze w miarę ogarniam i bardziej mnie interesuję jak zrobić ten baner. Z kodem powyżej gra działa tak samo jak i bez niego, czyli banera nie ma, ani nic zastępczego. Extension oczywiście jest dodany.