Hi Mo,
I think this is not the best way to handle it.
Did you take a look at their example at github ?
-- show an ad if one has been downloaded and is available for playback function showAd() ads.show( "interstitial", { isBackButtonEnabled = true } ) end -- event table includes: -- event.name = 'adsRequest' -- event.provider = 'vungle' -- event.type (string - e.g. 'adStart', 'adView', 'adEnd') -- event.isError (boolean) -- event.response (string) -- create a 'function' ad listener function functionAdListener( event ) -- video ad not yet downloaded and available if event.type == "adStart" and event.isError then statusText.text = "Downloading video ad ..." statusText.x = display.contentWidth \* 0.5 -- wait 5 seconds before retrying to display ad timer.performWithDelay(5000, showAd) -- video ad displayed and then closed elseif event.type == "adEnd" then statusText.text = "Hope you enjoyed the video!" statusText.x = display.contentWidth \* 0.5 else print( "Received event:") vardump( event ) end end
They wait a bit if this is true and then try to call the ad again.
if event.type == "adStart" and event.isError then
Guess this is because a video ad takes time to load.
If I was you, I would call showRevmob() if you get the event.isError the second time.
Anyway, I think they miss a call that would pre-cash the video ad, something like ad.cache().
Then we could call if(ads.isAdAvailable()) ads.show() at any time we think is best for the user experience.
The problem I see right now is that if I call the ads.show() at game start, the user switches to the game-play screen and starts playing, and suddenly the video ad shows is not the best experience.
With ads.cache() we could call it on game start and the call ads.show() e.g. when the user finish playing.
Regards,
Damir.