Jump to content

Intel Xdk Phaser Amazon ads


Rafaelx
 Share

Recommended Posts

I'm just about to finish my very first game but I'm having issues adding Amazon ads on it. I'm working on the game using Intel Xdk and Phaser of course, I find phaser to be very superior and a good engine, now everything I think is clean and work smoothly so far. I have completed 80% of my game, the problem I'm having is, I would like to ad Amazon ads into my game. Why Amazon and not google you may ask, well I got banned from google apparently cause of invalid traffic or something like that, funny thing I live in Cayman Islands and I'm unable to display the ads here, so I was sending to friends to test, maybe they messed up for me who knows.

I downloaded the Amazon Mobile ads for Cordova and successfully added the ads plug in into my project, in there there inside the www folder I find AmazonMobileAds this is its content:

/* 
* Copyright 2014 Amazon.com,
* Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the
* "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and
* limitations under the License.
*/

var cordova = require('cordova');
var exec = require('cordova/exec');

var AmazonMobileAds = function() {
}
var serviceName = 'AmazonMobileAdsPlugin';
AmazonMobileAds.prototype = {
    listeners : [],
    addListener: function(eventId, listener){
               if (typeof this.listeners[eventId] == "undefined") {
                    this.listeners[eventId] = [];
               }

               this.listeners[eventId].push(listener);
               console.log('Listener was added for an event');
    },

    removeListener: function(eventId, listener) {
               if (typeof this.listeners[eventId] != "undefined") {
                    for (var i = this.listeners[eventId].length; i--; ) {
                        if (this.listeners[eventId][i] == listener) {
                            this.listeners[eventId].splice(i, 1);
                        }
                    }
               }
    },

    fire: function(event) {   
               if (typeof event == "string") {
                   event = JSON.parse(event
                           .replace(/\n/g, "\\n")
                           .replace(/\r/g, "\\r")
                           .replace(/\t/g, "\\t")
                           .replace(/\f/g, "\\f"));
                }

                if (!event.eventId) {
                    throw new Error("Event object missing 'eventId' property.");
                }
                console.log('Event received');
                if (this.listeners[event.eventId] instanceof Array) {
                    var listeners = this.listeners[event.eventId];
                    for (var i = 0, len = listeners.length; i < len; i++) {
                        listeners[i].call(this, event);
                    }
                }
    }
};

AmazonMobileAds.prototype.setApplicationKey = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'setApplicationKey', options)
};

AmazonMobileAds.prototype.registerApplication = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'registerApplication', options)
};

AmazonMobileAds.prototype.enableLogging = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'enableLogging', options)
};

AmazonMobileAds.prototype.enableTesting = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'enableTesting', options)
};

AmazonMobileAds.prototype.enableGeoLocation = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'enableGeoLocation', options)
};

AmazonMobileAds.prototype.createFloatingBannerAd = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'createFloatingBannerAd', options)
};

AmazonMobileAds.prototype.createInterstitialAd = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'createInterstitialAd', options)
};

AmazonMobileAds.prototype.loadAndShowFloatingBannerAd = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'loadAndShowFloatingBannerAd', options)
};

AmazonMobileAds.prototype.loadInterstitialAd = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'loadInterstitialAd', options)
};

AmazonMobileAds.prototype.showInterstitialAd = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'showInterstitialAd', options)
};

AmazonMobileAds.prototype.closeFloatingBannerAd = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'closeFloatingBannerAd', options)
};

AmazonMobileAds.prototype.isInterstitialAdReady = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'isInterstitialAdReady', options)
};

AmazonMobileAds.prototype.areAdsEqual = function(successCallback, errorCallback, options) {
    exec(successCallback, errorCallback, serviceName, 'areAdsEqual', options)
};

AmazonMobileAds.prototype.AdType = {
FLOATING:'FLOATING',
INTERSTITIAL:'INTERSTITIAL'
}

AmazonMobileAds.prototype.Dock = {
TOP:'TOP',
BOTTOM:'BOTTOM'
}

AmazonMobileAds.prototype.HorizontalAlign = {
LEFT:'LEFT',
CENTER:'CENTER',
RIGHT:'RIGHT'
}

AmazonMobileAds.prototype.AdFit = {
FIT_SCREEN_WIDTH:'FIT_SCREEN_WIDTH',
FIT_AD_SIZE:'FIT_AD_SIZE'
}

module.exports = new AmazonMobileAds();
So then I have no idea how to call my ad in my code. All I want to do is maybe display a Floating ad when the player dies, this is all HTML5 and I cannot find a single example out there. I been trying different things using the reference on the results of this google search but I still find my self unable to add the ad, my base template that I use to make my game is found here: Intel XDK Template I used, I would really appreciate any help or suggestion or a single tip to guide me to add this into my project.  
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...