2014-01-08 00:34:47 +00:00
|
|
|
BasicGame = {
|
|
|
|
|
|
|
|
/* Here we've just got some global level vars that persist regardless of State swaps */
|
|
|
|
score: 0,
|
|
|
|
|
|
|
|
/* If the music in your game needs to play through-out a few State swaps, then you could reference it here */
|
|
|
|
music: null,
|
|
|
|
|
|
|
|
/* Your game can check BasicGame.orientated in internal loops to know if it should pause or not */
|
|
|
|
orientated: false
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
BasicGame.Boot = function (game) {
|
|
|
|
};
|
|
|
|
|
|
|
|
BasicGame.Boot.prototype = {
|
|
|
|
|
|
|
|
preload: function () {
|
|
|
|
|
|
|
|
// Here we load the assets required for our preloader (in this case a background and a loading bar)
|
|
|
|
this.load.image('preloaderBackground', 'images/preloader_background.jpg');
|
|
|
|
this.load.image('preloaderBar', 'images/preloadr_bar.png');
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
create: function () {
|
|
|
|
|
2014-02-25 14:46:48 +00:00
|
|
|
this.input.maxPointers = 1;
|
|
|
|
this.stage.disableVisibilityChange = true;
|
2014-01-08 00:34:47 +00:00
|
|
|
|
|
|
|
if (this.game.device.desktop)
|
|
|
|
{
|
2014-02-25 14:46:48 +00:00
|
|
|
this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
|
|
|
|
this.scale.minWidth = 480;
|
|
|
|
this.scale.minHeight = 260;
|
|
|
|
this.scale.maxWidth = 1024;
|
|
|
|
this.scale.maxHeight = 768;
|
|
|
|
this.scale.pageAlignHorizontally = true;
|
|
|
|
this.scale.pageAlignVertically = true;
|
|
|
|
this.scale.setScreenSize(true);
|
2014-01-08 00:34:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-02-25 14:46:48 +00:00
|
|
|
this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
|
|
|
|
this.scale.minWidth = 480;
|
|
|
|
this.scale.minHeight = 260;
|
|
|
|
this.scale.maxWidth = 1024;
|
|
|
|
this.scale.maxHeight = 768;
|
|
|
|
this.scale.pageAlignHorizontally = true;
|
|
|
|
this.scale.pageAlignVertically = true;
|
|
|
|
this.scale.forceOrientation(true, false);
|
2014-09-01 01:52:45 +00:00
|
|
|
this.scale.setResizeCallback(this.gameResized, this);
|
2014-02-25 14:46:48 +00:00
|
|
|
this.scale.enterIncorrectOrientation.add(this.enterIncorrectOrientation, this);
|
|
|
|
this.scale.leaveIncorrectOrientation.add(this.leaveIncorrectOrientation, this);
|
|
|
|
this.scale.setScreenSize(true);
|
2014-01-08 00:34:47 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 14:46:48 +00:00
|
|
|
this.state.start('Preloader');
|
2014-01-08 00:34:47 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
gameResized: function (width, height) {
|
|
|
|
|
|
|
|
// This could be handy if you need to do any extra processing if the game resizes.
|
2014-09-01 01:52:45 +00:00
|
|
|
// A resize could happen if for example swapping orientation on a device or resizing the browser window.
|
2014-01-08 00:34:47 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
enterIncorrectOrientation: function () {
|
|
|
|
|
|
|
|
BasicGame.orientated = false;
|
|
|
|
|
|
|
|
document.getElementById('orientation').style.display = 'block';
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
leaveIncorrectOrientation: function () {
|
|
|
|
|
|
|
|
BasicGame.orientated = true;
|
|
|
|
|
|
|
|
document.getElementById('orientation').style.display = 'none';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|