1

i have a question with corona (LUA), at the moment im showing interstitial ad when tap button occurs. I have this and its working (sometimes takes like 5-10-15 seconds to load and ad, i dont know why:

local ads = require("ads")
local interstitialAppID = "ca-app-pub-xxxxxxxxxx/xxxxxxxx21"
local testMode = true

local adProvider = "admob"
local function adListener( event )

if ( event.isError ) then
    print ( "Error en el anuncio!", msg )

elseif ( event.phase == "loaded") then
    print ( "Anuncio cargado!", msg )

elseif ( event.phase == "shown") then
    print ( "Cargando nuevo anuncio!", msg )
    ads.load ("interstitial", { appId = interstitialAppID, testMode = isTestMode } )
end
end

ads.init("admob", interstitialAppID, adListener )
ads.load ("interstitial", { appId = interstitialAppID, testMode = isTestMode } )

-- INTERSTITIAL AD
local function Adinterstatial( self, event )
ads.show( "interstitial", { appId = interstitialAppID, testMode = isTestMode 
} )
end     

local test = display.newImageRect( "Lore/0.png", 50, 50 )
test.x = 150
test.y = 150
test.tap = Adinterstatial
test:addEventListener( "tap" )

I want to do this for example: every 20 taps (on all the app) shows an interistitial ad. Is this possible? How i can do it?

Thanks.

1 Answers1

0

You can add a Runtime tap event. This will get all taps on the screen, it does not matter where or what object was tapped. For example:

local numTaps = 0
local function countTaps()
    numTaps = numTaps + 1
    if numTaps % 20 == 0 then
        -- Show the add here.
    end
end

Runtime:addEventListener("tap", countTaps)

The % gets the remaindeer of the division between numTaps and 20. This means that it will be 0 every 20 taps.

Basilio German
  • 1,801
  • 1
  • 13
  • 22