Module: ads
Table of contents
Functions
Functions
showInterstitial
▸ showInterstitial(placement
, description
, beforeAd
, afterAd
): void
Shows an interstitial ad. These can be shown at various points in the game such as a level end, restart or a timed interval in games with longer levels.
Example
// Player reached the next level.
Wortal.ads.showInterstitial('next', 'NextLevel', pauseGame, resumeGame);
// Player paused the game.
Wortal.ads.showInterstitial('pause', 'PausedGame', pauseGame, resumeGame);
// Player opened the IAP shop.
Wortal.ads.showInterstitial('browse', 'BrowseShop', pauseAudio, resumeAudio);
Parameters
Name | Type | Description |
---|---|---|
placement |
PlacementType |
Placement type for the ad. |
description |
string |
Description of the placement. |
beforeAd |
Function |
Callback for before the ad is shown. Pause the game here. |
afterAd |
Function |
Callback for after the ad is shown. Resume the game here. |
Returns
void
Throws
INVALID_PARAM
showRewarded
▸ showRewarded(description
, beforeAd
, afterAd
, adDismissed
, adViewed
): void
Shows a rewarded ad. These are longer, optional ads that the player can earn a reward for watching. The player must be notified of the ad and give permission to show before it can be shown.
Example
// This example shows the game flow independent of the outcome of the ad.
Wortal.ads.showRewarded('BonusCoins', pauseGame, resumeGame, skipBonus, addBonusCoins);
// This example shows the game flow depending on the outcome of the ad.
Wortal.ads.showRewarded('ReviveAndContinue', pauseAudio, resumeAudio, endGame, continueGame);
Parameters
Name | Type | Description |
---|---|---|
description |
string |
Description of the placement. |
beforeAd |
Function |
Callback for before the ad is shown. Pause the game here. |
afterAd |
Function |
Callback for after the ad is shown. Resume the game here. |
adDismissed |
Function |
Callback for when the player dismissed the ad. Do not reward the player. |
adViewed |
Function |
Callback for when the player has successfully watched the ad. Reward the player here. |
Returns
void
Throws
INVALID_PARAM
PlacementType
PlacementType: "preroll"
| "start"
| "pause"
| "next"
| "browse"
| "reward"
Types of ad placements as defined by Google: https://developers.google.com/ad-placement/docs/placement-types
-
start: Your game has loaded, the UI is visible and sound is enabled, the player can interact with the game, but the game play has not started yet.
-
pause: The player pauses the game.
-
next: The player navigates to the next level.
-
browse: The player explores options outside of gameplay.
NOTE: Use ads.showRewarded() which will automatically add the 'reward' type for rewarded ad calls.