From a80ffff0e871b6055412050ac785b47fb75f7c40 Mon Sep 17 00:00:00 2001 From: Alexandre Ferreira Date: Wed, 18 Nov 2015 19:45:06 -0300 Subject: [PATCH] Fixed accelerometer sensitivity Fixed ads when connection is offline Fixed interstitial ads backscreen color --- config.xml | 7 ++++--- www/js/Ads.js | 13 ++++++++++--- www/js/Boot.js | 8 ++++---- www/js/Game.js | 29 ++++++++++++++++++----------- www/js/GameOver.js | 5 ++++- www/js/Preloader.js | 2 +- 6 files changed, 41 insertions(+), 23 deletions(-) diff --git a/config.xml b/config.xml index 6f0321f..bfbf47f 100644 --- a/config.xml +++ b/config.xml @@ -1,17 +1,18 @@ - + Embaixadinha A TAP game that you have to keep the ball in the air. - - BroFist Team + + BroFist Corp + diff --git a/www/js/Ads.js b/www/js/Ads.js index a584cfc..c0f8d04 100644 --- a/www/js/Ads.js +++ b/www/js/Ads.js @@ -4,9 +4,9 @@ define(['phaser'], function (Phaser) { function Ads (game) { // listen when ad is closed document.addEventListener('onAdDismiss', function (data) { - if (!localStorage.quit) + if (localStorage.quit == 0) game.state.start('Game'); - else + else if (localStorage.quit == 1) game.state.start('Menu'); }); } @@ -14,9 +14,16 @@ define(['phaser'], function (Phaser) { Ads.prototype.constructor = Ads; Ads.prototype.create = function () { + // set backscreen color + this.game.stage.backgroundColor = '#000'; + // start admob - if (AdMob) + if (AdMob && navigator.connection.type !== Connection.NONE) AdMob.showInterstitial(); + else if (localStorage.quit == 0) + this.game.state.start('Game'); + else if (localStorage.quit == 1) + this.game.state.start('Menu'); }; return Ads; diff --git a/www/js/Boot.js b/www/js/Boot.js index f337f8c..a58ad20 100644 --- a/www/js/Boot.js +++ b/www/js/Boot.js @@ -2,7 +2,7 @@ define(['phaser', 'Preloader', 'Menu', 'Game', 'GameOver', 'Ads'], function (Pha 'use strict'; function Boot (game) { - // code me! + // use init method! } Boot.prototype.constructor = Boot; @@ -15,21 +15,21 @@ define(['phaser', 'Preloader', 'Menu', 'Game', 'GameOver', 'Ads'], function (Pha Boot.prototype.create = function () { // start analytics - analytics.startTrackerWithId('UA-70227806-2'); + window.analytics.startTrackerWithId('UA-70227806-2'); // start admob if (AdMob) { AdMob.createBanner({ adId: 'ca-app-pub-7403543083567100/2876399875', autoShow: false, - isTesting: true, + isTesting: false, overlap: true }); AdMob.prepareInterstitial({ adId: 'ca-app-pub-7403543083567100/4353133078', autoShow: false, - isTesting: true, + isTesting: false, overlap: true }); } diff --git a/www/js/Game.js b/www/js/Game.js index 8501e10..d7a58ce 100644 --- a/www/js/Game.js +++ b/www/js/Game.js @@ -4,7 +4,20 @@ define(['phaser'], function (Phaser) { var global_ball; function Game (game) { - // the ball + // use init method! + } + + Game.prototype.constructor = Game; + + Game.prototype.init = function () { + // google analytics track game screen + window.analytics.trackView('Game Screen'); + + // show admob + if (AdMob) + AdMob.showBanner(AdMob.AD_POSITION.BOTTOM_CENTER); + + // the ball this._ball = null; // kick timer @@ -33,15 +46,9 @@ define(['phaser'], function (Phaser) { // sfx new record this._sfxCelebration = null; - } - - Game.prototype.constructor = Game; + }; Game.prototype.create = function () { - // show admob - if (AdMob) - AdMob.showBanner(AdMob.AD_POSITION.BOTTOM_CENTER); - // start arcade physics this.game.physics.startSystem(Phaser.Physics.ARCADE); @@ -73,14 +80,14 @@ define(['phaser'], function (Phaser) { // setup accelerometer this._watchAccID = navigator.accelerometer.watchAcceleration( function (acceleration) { - global_ball.body.acceleration.x += acceleration.x * -1; + global_ball.body.velocity.x += acceleration.x * -1; }, function () { throw '[ERROR] Can\'t get acceleration values.'; }, - { frequency: 50 } + { frequency: 10 } ); // add timer title @@ -120,7 +127,7 @@ define(['phaser'], function (Phaser) { if (this.game.time.now > this._kickTimer) { this._sfxKick.play(); this._ball.body.velocity.y = -500; - this._kickTimer = this.game.time.now + 500; + this._kickTimer = this.game.time.now + 850; } }; diff --git a/www/js/GameOver.js b/www/js/GameOver.js index 291b1b7..2778509 100644 --- a/www/js/GameOver.js +++ b/www/js/GameOver.js @@ -2,7 +2,7 @@ define(['phaser'], function (Phaser) { 'use strict'; function GameOver (game) { - // code me! + // use init method! } GameOver.prototype.constructor = GameOver; @@ -55,6 +55,9 @@ define(['phaser'], function (Phaser) { localStorage.newGameCount = Number(localStorage.newGameCount) + 1; if (localStorage.newGameCount == 3) { + if (AdMob) + AdMob.hideBanner(); + localStorage.newGameCount = 0; localStorage.quit = 0; this.game.state.start('Ads'); diff --git a/www/js/Preloader.js b/www/js/Preloader.js index 94fee68..7612921 100644 --- a/www/js/Preloader.js +++ b/www/js/Preloader.js @@ -2,7 +2,7 @@ define(['phaser'], function (Phaser) { 'use strict'; function Preloader (game) { - // code me! + // use init method! } Preloader.prototype.constructor = Preloader;