@ad4game/phaser-a4g 中文文档教程
这是一个 Phaser HTML5 框架插件,可将 Google Adx 和 A4G 视频前置广告集成到您的 HTML5 游戏中。
我们创建它的原因和目标受众:
- We love games, especially the HTML5 flavour.
- We have created this plugin to help our existing and future customers monetise their Phaser games.
- All of our HTML5 publishers, who tried video pre-roll, generated higher revenues.
- Why AdX and not Adsense? Adx is paid by CPM and should generate better profits.
A4G Demo usage
这个 github 存储库中的游戏展示了如何将视频前置广告集成到 HTML5 框架 Phaser 游戏中。 查看显示视频预滚动的工作演示:http://xmmorpg.com/phaser-a4g/
集成步骤:
- First include
a4g-ad-plugin.js
into your codebase. - Then create the A4gPlugin:
game.a4gPlugin = game.plugins.add(A4gPlugin.configure({
zone: YOUR_ZONE_ID
}));
- Whenever you want to show an ad within your game just call
showAd()
function. Typically game developers call this function on the beginning of the game and between the levels.
game.a4gPlugin.showAd();
为了集成此插件,您需要 YOUR_ZONE_ID
。 除非您是现有客户,否则请在以下网址注册为发行商/网站:http://www.a4g.com/#get-contacted 并添加一条消息,说明您正在注册 Phaser HTML5 游戏。
注意:Adx有严格的加入要求。 我们将帮助您完成设置过程,使其尽可能顺利。
NPM
您可以从这里获取最新的 NPM:https://www.npmjs.com/package/@ad4game/phaser-a4g
npm install @ad4game/phaser-a4g --save-dev
A4g Phaser Plugin API
A4gPlugin.configure(config)
creates preconfigured A4gPhaser plugin. It takes 1 parameter, configuration. Configuration is a regular JavaScript object, which can take following settings:zone
zone id from A4g (required)adTypes
array of ad types that can be displayed. Available values are['video', 'skippablevideo', 'standardvideo', 'text', 'image']
, default value is['video']
which is equivalent tostandardvideo_skippablevideo
, see required params / ad_type for more info: https://support.google.com/adsense/answer/3112148skipOffset
number of seconds when ad can be skipped, default value is10
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.timeout
number of milliseconds which indicate ad timeout. It serve for cases if something would go wrong, default value is 35000pauseGame
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 ifpauseGame
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 completed- You can fully control the styling of the div showing the ad. Our publishers often display games in an iframe, which autoscales to 100%.
参考资料:
- http://phaser.io/
- https://github.com/photonstorm/phaser
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:
- We love games, especially the HTML5 flavour.
- We have created this plugin to help our existing and future customers monetise their Phaser games.
- All of our HTML5 publishers, who tried video pre-roll, generated higher revenues.
- Why AdX and not Adsense? Adx is paid by CPM and should generate better profits.
A4G Demo usage
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: http://xmmorpg.com/phaser-a4g/
Integration steps:
- First include
a4g-ad-plugin.js
into your codebase. - Then create the A4gPlugin:
game.a4gPlugin = game.plugins.add(A4gPlugin.configure({
zone: YOUR_ZONE_ID
}));
- Whenever you want to show an ad within your game just call
showAd()
function. Typically game developers call this function on the beginning of the game and between the levels.
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.
NPM
You can get the lates NPM from here: https://www.npmjs.com/package/@ad4game/phaser-a4g
npm install @ad4game/phaser-a4g --save-dev
A4g Phaser Plugin API
A4gPlugin.configure(config)
creates preconfigured A4gPhaser plugin. It takes 1 parameter, configuration. Configuration is a regular JavaScript object, which can take following settings:zone
zone id from A4g (required)adTypes
array of ad types that can be displayed. Available values are['video', 'skippablevideo', 'standardvideo', 'text', 'image']
, default value is['video']
which is equivalent tostandardvideo_skippablevideo
, see required params / ad_type for more info: https://support.google.com/adsense/answer/3112148skipOffset
number of seconds when ad can be skipped, default value is10
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.timeout
number of milliseconds which indicate ad timeout. It serve for cases if something would go wrong, default value is 35000pauseGame
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 ifpauseGame
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 completed- You can fully control the styling of the div showing the ad. Our publishers often display games in an iframe, which autoscales to 100%.
References:
- http://phaser.io/
- https://github.com/photonstorm/phaser
你可能也喜欢
- 65710f05-a7c1-48d1-9ee5-acdfb7f70007 中文文档教程
- 8b10b 中文文档教程
- @0655-dev/template-dhall-package 中文文档教程
- @0x-lerna-fork/output 中文文档教程
- @107v/grapesjs-image-manager 中文文档教程
- @21epub/functional-button 中文文档教程
- @2alheure/vue-datatable 中文文档教程
- @7174n/eslint-config 中文文档教程
- @abu-sufian/isemptyarray 中文文档教程
- @acastellon/arango 中文文档教程