At the moment I am using adcolony for my rewarded video/interstitials.
my rewarded videos are working perfectly but I’m having touble showing an interstitial ad… should’nt be so complicated and still cannot understand how can I solve this. help would be apreeciated alot. Ill paste the relevant code down here…
main.lua
adcolony = require( "plugin.adcolony" ) local rewardFlag = false -- AdColony listener function local function acListener( event ) if ( event.phase == "init" ) then -- Successful initialization print( event.provider ) adcolony.show( "interstitial" ); elseif( event.phase == "displayed" ) then elseif( event.phase == "closed" ) then if( event.type == "rewardedVideo" ) then if( rewardFlag == true ) then myData.rewardEarned = true; end elseif( event.type == "interstitial" ) then composer.gotoScene( "gameOver", { effect = "fade", time = 50 } ); end elseif( event.phase == "loaded" ) then elseif( event.phase == "reward" ) then print( event.data ); if( rewardFlag == false ) then rewardFlag = true; end end end -- Initialize the AdColony plugin with your Corona Ads API key adcolony.init( acListener, { apiKey="\*\*\*\*" } )
game.lua
if( myData.timeToShowAd == 2 ) then composer.gotoScene( "interAd", { effect = "fade", time = 200 } ); else composer.gotoScene( "gameOver", { effect = "fade", time = 200 } ); end
interAd.lua
function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then if( adcolony.isLoaded( "interstitial" ) ) then myData.timeToShowAd = 0; adcolony.show( "interstitial" ); else composer.gotoScene( "gameOver", { effect = "fade", time = 50 } ); end end end
at that points the game freezes and must force quit the game to play again…
Thank you for you time,
Itay