![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@azerion/phaser-ads
Advanced tools
A Phaser plugin for providing nice ads integration in your phaser.io game
This repository is to be considered DEPRECATED and all efforts are going towards developing the next version of the Ad Wrapper in azerion/h5-ad-wrapper.
This Phaser plugin that allows you to leverage different ad providers whilst providing the same simple API. Also allows you to easily integrate mobile ads (via Cocoon).
Key features:
First you want to get a fresh copy of the plugin. You can get it from this repo or from npm.
npm install @azerion/phaser-ads
Next up you'd want to add it to your list of js sources you load into your game:
<script src="path/to/phaser-ads.min.js"></script>
You could also opt for using the (free) jsdelivr cdn:
<script src="https://cdn.jsdelivr.net/npm/@azerion/phaser-ads@latest/build/phaser-ads.min.js"></script>
After adding the script to the page you can activate it by enabling the plugin:
game.add.plugin(PhaserAds.AdManager);
First thing you need to do after loading the plugin is attaching a provider to the adManager. PhaserAds comes pre-compiled with 4 providers for you to choose from:
If you already have an account on Gamedistribution.com you can skip this introduction if not, head on over to gamedistribution.com and sign up for a free account. Once you're signed up you can check out this guide for settings up a game. This is important because this will supply you with a gameId, which you need to supply to the plugin.
So when you have your gameId you can start by registering the provider to the plugin:
// Let's create a new provider, first argument should be the game, second should be the ad tag URL
var provider = new PhaserAds.AdProvider.GameDistributionAds(
game, // Your Phaser game instance
'2d77cfd4b1e5487d998465c29de195b3' // Your gameId
);
game.ads.setAdProvider(provider);
After this it's as easy as calling:
game.ads.showAd();
A provider can use any number of arguments configured in order to make it work, it all depends on the implementation that was made by the developer. For our IMA Provider you can create one like this:
// Let's create a new provider, first argument should be the game, second should be the ad tag URL
var provider = new PhaserAds.AdProvider.Ima3(
game,
'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&correlator'
);
game.ads.setAdProvider(provider);
Now all you need to do is request an ad, and add an event listener that is called when the ad is completed/skipped/finished/done playing.
game.ads.onContentResumed.addOnce(function() {
// This gets called when the ad is complete
game.state.start('NextState');
});
// Here we request the ad
game.ads.showAd();
You can also send custom parameters by adding them as an object to the showAd function.
This can happen, sometimes the provider does something wrong, but most of the time (and when you are testing locally) your ads get blocked from showing. That's right, ads don't show when testing locally. The easiest way to avoid this is by testing your game on a server (online).
Another work around would be to adjust your /etc/hosts.
The setup allows for a multitude of ad providers to work, but sadly we don't have the time and resources to add all of them. That beeing said, this plugin is on GitHub, and you're welcome to shoot in a PR to add a new provider =)
We at Azerion just love playing and creating awesome games. We aren't affiliated with Phaser.io. We just needed some awesome ads in our awesome HTML5 games. Feel free to use it for enhancing your own awesome games!
Phaser Ads is distributed under the MIT license. All 3rd party libraries and components are distributed under their respective license terms.
[2.4.1] 2019-11-15
FAQs
A Phaser plugin for providing nice ads integration in your phaser.io game
The npm package @azerion/phaser-ads receives a total of 11 weekly downloads. As such, @azerion/phaser-ads popularity was classified as not popular.
We found that @azerion/phaser-ads demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.