Im posting this code to see if it will help.
[lua]local function adListener( event )
if ( event.phase == “init” ) then – Successful initialization
print( event.provider )
– Load an StartApp ad
startapp.load( “interstitial” )
startapp.load( “video” )
elseif ( event.phase == “loaded” ) then – The ad was successfully loaded
print( event.type )
elseif ( event.phase == “failed” ) then – The ad failed to load
print( event.type )
print( event.isError )
print( event.response )
elseif ( event.phase == “displayed” ) then – The ad was displayed/played
print( event.type )
elseif ( event.phase == “hidden” ) then – The ad was closed/hidden
print( event.type )
elseif ( event.phase == “clicked” ) then – The ad was clicked/tapped
print( event.type )
elseif ( event.phase == “reward” ) then – Rewarded video ad playback completed
user.money = user.money + 50
loadsave.saveTable(user, “user.json”)
moneyText.text = user.money
startapp.load(“rewardVideo”)
print( “reward” )
print( event.type )
end
end
– Initialize the StartApp plugin
startapp.init( adListener, { appId="", enableReturnAds = true } )[/lua]
My main.lua updated /\
[lua]local function gotoMenu(event)
if(event.phase == “ended”) then
audio.play(clickSnd, {channel = 2})
physics.stop( )
display.remove(newFlag)
display.remove(newSpear)
display.remove(newCoin)
for i = #objTable, 1, -1 do
table.remove( objTable, i)
break
end
for i = #coinTable, 1, -1 do
table.remove( coinTable, i )
break
end
composer.removeScene(“game”)
composer.gotoScene(“menu”)
–show ad
–if ( startapp.isLoaded( “interstitial” ) ) then
startapp.show(“video”)
–end
end
end[/lua]
Trying to display a video ad, when going back to the menu screen. From my game.lua /\
[lua]local function playAd(event)
if (event.phase == “ended”) then
print( “button works” )
if startapp.isLoaded( “rewardedVideo” ) then
startapp.show(“rewardedVideo”)
end
end
end
startapp.load( “rewardedVideo” )[/lua]
This is my function to show my video reward ad. I have a button that calls it. This is from my shop.lua /\