Hi. why does the ad show after the scene appears? And how to fix it?
Here is my code.
local function handleButtonEvent( event )
if ( "ended" == event.phase ) then
ads:showInterstitial()
composer.gotoScene("answer")
end
end
Ads are preloaded. here is my ads.lua code
local admob = require( "plugin.admob" )
local ads = {}
ads.adListener = function(event)
if ( event.phase == "init" ) then
admob.load( "interstitial", { adUnitId="ca-app-pub-3940256099942544/1033173712" } )
end
if ( event.phase == "displayed" ) then
if ( admob.isLoaded( "interstitial" ) == false ) then
admob.load( "interstitial", { adUnitId="ca-app-pub-3940256099942544/1033173712" } )
end
end
if ( event.phase == "closed") then
composer.gotoScene("answer")
end
end
function ads:init()
admob.init( ads.adListener, { testMode = true } )
end
function ads:isL()
return admob.isLoaded( "interstitial" )
end
function ads:loadInterstitial()
admob.load( "interstitial", { adUnitId="ca-app-pub-3940256099942544/1033173712" } )
end
function ads:showInterstitial()
admob.show("interstitial")
end
return ads