We support two different types of video ads:
Midgame advertisements can happen when a user died, a level has been completed, etc.
Rewarded advertisements can be requested by the user in exchange for a reward (An additional life, a retry when the user died, a bonus starting item, extra starting health, etc.). Rewarded ads should be shown when users explicitly consent to watch an advertisement.
To react to an ad starting or finishing, the SDK offers three callbacks:
adError callback is also triggered if the ad is not filled.
For each callback, create a Godot function with one argument. Within these functions, you can, for example, emit custom signals that other scripts can connect and react to. For example, you should pause the game and mute the audio during an ad.
_ready function, add the three callbacks like this:
Now, to request an ad, call:
To detect if the user has an adblocker, the
ad module offers the method
Define a function to receive the result. From there, you can emit a signal for other scripts to connect to, for example.
Create a callback to it in global scope:
Through the callback, the SDK will return an array, the first element tells you whether an error occurred during adblock detection. If none occured, the second element tells you whether the user has an adblock active.