Android Library
(Old content)
Here I made a modified version of LÖVE 0.10.2, with a new module:
love.ads!
With this module is possible to request and display ads from LÖVE!
An AdMob account is needed in order to use this module.
(New content)
The library has been updated to LÖVE 11.3!
With this library you can display AdMob ads (banners, interstitial and rewarded video) and collect consent from the European users as required by the GPDR law (more info here)
I have added 11 functions and 5 callbacks:
love.ads Functions
- love.ads.createBanner(string adUnitID,string position)
string adUnitID : Your banner ad unit id.
string position : The position of the banner. Can be "top" or "bottom".
Initializes the banner ad without displaying it. This function may be fired only once.
The banner inizialized is a smart banner.
- love.ads.showBanner()
Displays the banner ad. This function may be fired after createBanner
- love.ads.hideBanner()
Hides the banner ad. This function may be fired after createBanner
- love.ads.requestInterstitial(string adUnitID)
string adUnitID : Your interstitial ad unit id.
Requests an interstitial ad. This function should be called every time a new ad is needed.
- love.ads.isInterstitialLoaded()
Check if the interstitial ad previously requested is ready to be shown.
Returns:
bool isAdReady: true if the ad is ready to be shown.
- love.ads.showInterstitial()
Displays the interstitial ad. May be called only if the ad is loaded.
- love.ads.requestRewardedAd(string adUnitID)
string adUnitID : Your rewarded ad unit id.
Requests a rewarded video ad. This function should be called every time a new ad is needed.
- love.ads.isRewardedAdLoaded()
Check if the rewarded video ad previously requested is ready to be shown.
Returns:
bool isAdReady: true if the ad is ready to be shown.
- love.ads.showRewardedAd()
Displays the rewarded video ad. May be called only if the ad is loaded.
- love.ads.getDeviceLanguage()
Returns:
string deviceLanguage: the code of the language set on the device. (Example: EN,FR,IT)
It can be useful for internationalization.
- love.ads.changeEUConsent()
Shows the Consent View to let the user change his consent.
- love.interstitialFailedToLoad()
Fired when an interstitial ad fails to load.
- love.interstitialClosed()
Fired when the user closes an interstitial ad.
- love.rewardedAdFailedToLoad()
Fired when a rewarded video ad fails to load.
- love.rewardUserWithReward(string rewardType,number rewardQuantity)
string rewardType : The type of the reward you set in your AdMob dashboard.
number rewardQuantity : The quantity of rewards you set in you AdMob dashboard.
Fired when a rewarded video ad successfully finishes playing.
- love.rewardedAdDidStop()
Fired when a rewarded video ad is closed by the user.
This callback is fired even if the video has already finished.
Here is the repository of the library:
https://bitbucket.org/bio1712/love2d-ad ... rc/master/
In order to use it, just open the Xcode project and build it!
Then, open liblove.xcodeproj/modules/ads/Ads.mm and:
1) Insert your privacy policy URL at line 81 (needed for Consent SDK)
2) Insert your application ID at line 82
3) Insert your publisher ID at line 83
4) Set up your test devices at line 89
You can disable the Consent SDK by turning the boolean collectConsent at line 84 to false.
Then open the file info.plist and set GADApplicationIdentifier with your AdMob app ID.
Included in the source, there is an example game.love.
Note: all the Ad-Unit IDs in the game.love are from this url.
Screenshots:
Second note: This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.