In case you have your heart set on ads, and more than just banner ads, this is basically how I approach ad code.
I find that many developers get very confused about how to write the listener and then how to ‘hook it into their game’. Many hard-code all the connections and that is (IMHO) wrong.
I connect the listener to my game via a second layer of custom events. I do this with a custom Ad module. It generally has these parts:
- init()
- Listener with hooks to generate events.
- enable/disable functions to enable/disable specific actions.
- show/hide helpers or listeners to show and hide ads using the current provider.
I know this probably sounds confusing, but essentially what this does is allow me to put all my ad code in one place and then selectively choose what it does when I need it.
Then, later I can access the module from main, my scenes, etc. and init(), enable events to reward the user, request an ad, hide ads, etc.
Sorry, if this still doesn’t make sense, but its the best I can do right now.
PS - Another way to handle it is like a state-machine where the states are changed as the result of:
- listener events and conditions
- function calls to the module