build.settings
[lua]
[“plugin.coronaAds”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
[“plugin.google.play.services”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
[“shared.android.support.v4”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android=true }
},
},
[/lua]
init in main.lua
[lua]
corona = require( “plugin.coronaAds” )
– Corona Event listener function
local function CoronaListener( event )
if ( event.phase == “init” ) then
– corona system initialized
DATA.readytoshowAd = true
print(“coronaAds init-ed from main.lua”)
elseif ( event.phase == “found” ) then
elseif ( event.phase == “failed” ) then
DATA.screenshowncount = 4
elseif ( event.phase == “shown” ) or ( event.phase == “closed” ) then
DATA.screenshowncount = 1
end
end
corona.init( “fdsafdsa fdsa fdsa fdsa fdas fsad fdsa”, CoronaListener )
[/lua]
call for ad in scorescreen.lua
[lua]
coronaAds = require( “plugin.coronaAds” )
----- control the loading and display of ads, and show the buttons at the proper time
local showCoronaAds = function ()
print(“showCoronaAds called”)
local alert
if DATA.adPurchased == false then
if DATA.displayAds == true then
print(“in showCoronaAds function”)
– count every third cycle
if DATA.screenshowncount >= 4 and DATA.readytoshowAd == true and DATA.adProvider == “Corona” then
local adPlacement = “interstitial-1”
–local adPlacement = “top-banner-320x50”
–alert = native.showAlert( “Ad - to be shown”, "Ad is ready to be shown, placement = "…adPlacement, { “OK”, “Cancel” } )
coronaAds.show( adPlacement, true )
else
DATA.screenshowncount = DATA.screenshowncount + 1
–print("screenshowncount = "…DATA.screenshowncount)
timers.t10 = timer.performWithDelay(1000,showButtons)
end
end
elseif DATA.adPurchased == true then
print (“in the adPurchased area of showCoronaAds”)
–alert = native.showAlert( “Ad free”, “In the DATA.adPurchased == true condition”, { “OK”, “Cancel” } )
timers.t10 = timer.performWithDelay(1000,showButtons)
end
–alert = native.showAlert( “in showCoronaAds”, “no condition”, { “OK”, “Cancel” } )
alert = nil
end
timers.t9 = timer.performWithDelay(200,showCoronaAds)
[/lua]