Please read (or re-read) this: http://docs.coronalabs.com/tutorial/basics/ads/index.html
Then read this: https://coronalabs.com/blog/2018/10/02/monetization-best-practices-and-a-new-ad-tutorial/
Absolutely do not initialize ads in game.lua.
Where are you preloading the ad (calling .load() )?
Absolutely do not force the user to view a rewardedVideo. This needs to be on a button where you ask them if they want to view the rewarded video and only show the ad if they say yes. It has to be the app user’s choice.
As far as how do you reward the video, that’s going to be really hard for anyone to answer because you have told us nothing about your in-game economy? What does the player get for viewing the video? If you’re giving them coins, the answer will be different than if you let them continue to the next level after losing or causing them to restart.
In generic terms, if you need to know if the reward view was complete in game.lua, then you can in game.lua do:
function scene:handleRewardedVideo( amount ) -- put your code here to do whatever you need to do end
Then in your listener function in main.lua, do something like:
local function appodealListener( event ) print("\*\*\* APPODEAL \*\*\*", event.phase) if ( event.phase == "init" ) then -- Successful initialization print( event.isError ) elseif event.phase == "playbackEnded" and event.data then local amount = event.data.amount local sceneName = composer.getSceneName("current") if sceneName == "game" then local scene = composer.getScene( scene ) scene:handleRewardedVideo( amount ) end end end
This basically grabs the current composer scene info and gets a reference to the scene’s scene object. Since you have created a function in game.lua that’s now a method of the scene object, you can call that function from the listener function.
Rob