Skip to content

Commit

Permalink
Fixed accelerometer sensitivity
Browse files Browse the repository at this point in the history
Fixed ads when connection is offline
Fixed interstitial ads backscreen color
  • Loading branch information
alexandresgf committed Nov 18, 2015
1 parent f0aa5eb commit a80ffff
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 23 deletions.
7 changes: 4 additions & 3 deletions config.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.brofistcorp.embaixadinha" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<widget id="com.brofistcorp.embaixadinha" version="1.2.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Embaixadinha</name>
<description>
A TAP game that you have to keep the ball in the air.
</description>
<author email="contact@brofistcorp.com" href="http://brofistcorp.com">
BroFist Team
<author email="brofistoficial@gmail.com" href="http://facebook.com/brofistcorp">
BroFist Corp
</author>
<content src="index.html" />
<preference name="Fullscreen" value="true" />
<preference name="Orientation" value="portrait" />
<plugin name="cordova-plugin-whitelist" version="1" />
<plugin name="Accelerometer" value="org.apache.cordova.AccelListener" />
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager" />
<access origin="*" />
<allow-navigation href="http://*/*" />
<allow-intent href="http://*/*" />
Expand Down
13 changes: 10 additions & 3 deletions www/js/Ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@ 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');
});
}

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;
Expand Down
8 changes: 4 additions & 4 deletions www/js/Boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
});
}
Expand Down
29 changes: 18 additions & 11 deletions www/js/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
};

Expand Down
5 changes: 4 additions & 1 deletion www/js/GameOver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define(['phaser'], function (Phaser) {
'use strict';

function GameOver (game) {
// code me!
// use init method!
}

GameOver.prototype.constructor = GameOver;
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion www/js/Preloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define(['phaser'], function (Phaser) {
'use strict';

function Preloader (game) {
// code me!
// use init method!
}

Preloader.prototype.constructor = Preloader;
Expand Down

0 comments on commit a80ffff

Please sign in to comment.