Phaser plugin allowing Video and HTML5 ad integrations with phaser.io games
MIT License
This is a Phaser HTML5 framework plugin to integrate both Google Adx and A4G video pre-roll ads into your HTML5 games.
Why we've created it and the target audience:
The game from this github repository shows how a video pre-roll ad can be integrated into HTML5 framework Phaser game. See a working demo showing a video pre-roll and inter-game ad each 60 seconds: http://xmmorpg.com/phaser-a4g/example/
Integration steps:
a4g-ad-plugin.js
into your codebase.game.a4gPlugin = game.plugins.add(A4gPlugin.configure({
zone: YOUR_ZONE_ID
}));
showAd()
function.game.a4gPlugin.onAdComplete.add(function () {
console.log('Ad has been completed');
});
game.a4gPlugin.showAd();
In order to integrate this plugin you will need YOUR_ZONE_ID
. Unless you are an existing customer, please sign-up as a publisher / website at: http://www.a4g.com/#get-contacted and add a message saying that you are signing up for a Phaser HTML5 game.
Note: Adx has rigorous requirements to join. We will help you with the set-up process to make it as smooth as possible.
You can get the latest NPM from here: https://www.npmjs.com/package/@ad4game/phaser-a4g
npm install @ad4game/phaser-a4g --save-dev
A4gPlugin.configure(config)
creates preconfigured A4gPhaser plugin. It takes 1 parameter, configuration.zone
zone id from A4g (required)adTypes
array of ad types that can be displayed. Available values are ['video', 'skippablevideo', 'standardvideo', 'bumpervideo', 'text', 'image']
, default value is ['video']
which is equivalent to [standardvideo', 'bumpervideo', 'skippablevideo
], see required params / ad_type for more info: https://support.google.com/adsense/answer/3112148
skipOffset
number of seconds when ad can be skipped, default value is 10
fallbackZone
zone id which could be used in case the video cannot be loaded, by default not set. In case the Adx ad will not be loaded we will load a replacement ad (usually with a lower CPM). This could be useful if Adx fills a very small percentage of requests.pauseGame
boolean indicates if game should be paused while ad is shown, default value is trueunpauseGameDelay
number of milliseconds to wait for unpausing game after ad is hidden (will be used only if pauseGame
set to true), default value is 500A4gPlugin.prototype.showAd()
shows an adA4gPlugin.prototype.onAdShown
Phaser.Signal
would be triggered when ad shownA4gPlugin.prototype.onAdComplete
Phaser.Signal
would be triggered when ad showing is completedReferences: