Loader can now parse both JSON Hash and JSON Array formated texture atlas files.

This commit is contained in:
Richard Davey
2013-08-29 22:53:55 +01:00
parent 5b036557c0
commit 4c1dacfa02
10 changed files with 205 additions and 50 deletions
+1 -3
View File
@@ -278,7 +278,7 @@ Phaser.Game.prototype = {
this.load.onLoadComplete.add(this.loadComplete, this);
this.state.boot();
this.stage.boot();
// this.stage.boot();
// this.input.boot();
if (this.renderType == Phaser.CANVAS)
@@ -331,8 +331,6 @@ Phaser.Game.prototype = {
*/
loadComplete: function () {
console.log('loadComplete', this);
this._loadComplete = true;
this.state.loadComplete();
+19 -23
View File
@@ -13,6 +13,25 @@ Phaser.Stage = function (game) {
this.game = game;
// Get the offset values (for input and other things)
this.offset = new Phaser.Point;
Phaser.Canvas.getOffset(this.game.renderer.view, this.offset);
this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, this.game.width, this.game.height);
var _this = this;
this._onChange = function (event) {
return _this.visibilityChange(event);
}
document.addEventListener('visibilitychange', this._onChange, false);
document.addEventListener('webkitvisibilitychange', this._onChange, false);
document.addEventListener('pagehide', this._onChange, false);
document.addEventListener('pageshow', this._onChange, false);
window.onblur = this._onChange;
window.onfocus = this._onChange;
};
Phaser.Stage.prototype = {
@@ -21,29 +40,6 @@ Phaser.Stage.prototype = {
bounds: null,
offset: null,
boot: function () {
// Get the offset values (for input and other things)
this.offset = new Phaser.Point;
Phaser.Canvas.getOffset(this.game.renderer.view, this.offset);
this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, this.game.width, this.game.height);
var _this = this;
this._onChange = function (event) {
return _this.visibilityChange(event);
}
document.addEventListener('visibilitychange', this._onChange, false);
document.addEventListener('webkitvisibilitychange', this._onChange, false);
document.addEventListener('pagehide', this._onChange, false);
document.addEventListener('pageshow', this._onChange, false);
window.onblur = this._onChange;
window.onfocus = this._onChange;
},
/**
* This method is called when the document visibility is changed.
+19 -19
View File
@@ -102,8 +102,8 @@ Phaser.StateManager.prototype = {
if (this._pendingState !== null)
{
console.log('_pendingState found');
console.log(typeof this._pendingState);
// console.log('_pendingState found');
// console.log(typeof this._pendingState);
if (typeof this._pendingState === 'string')
{
@@ -129,26 +129,26 @@ Phaser.StateManager.prototype = {
if (typeof autoStart === "undefined") { autoStart = false; }
console.log('Phaser.StateManager.addState', key);
console.log(typeof state);
console.log('autoStart?', autoStart);
// console.log('Phaser.StateManager.addState', key);
// console.log(typeof state);
// console.log('autoStart?', autoStart);
var newState;
if (state instanceof Phaser.State)
{
console.log('Phaser.StateManager.addState: Phaser.State given');
// console.log('Phaser.StateManager.addState: Phaser.State given');
newState = state;
newState.link(this.game);
}
else if (typeof state === 'object')
{
console.log('Phaser.StateManager.addState: Object given');
// console.log('Phaser.StateManager.addState: Object given');
newState = state;
}
else if (typeof state === 'function')
{
console.log('Phaser.StateManager.addState: Function given');
// console.log('Phaser.StateManager.addState: Function given');
newState = new state(this.game);
}
@@ -158,12 +158,12 @@ Phaser.StateManager.prototype = {
{
if (this.game.isBooted)
{
console.log('Game is booted, so we can start the state now');
// console.log('Game is booted, so we can start the state now');
this.start(key);
}
else
{
console.log('Game is NOT booted, so set the current state as pending');
// console.log('Game is NOT booted, so set the current state as pending');
this._pendingState = key;
}
}
@@ -203,7 +203,7 @@ Phaser.StateManager.prototype = {
*/
start: function (key, clearWorld, clearCache) {
console.log('Phaser.StateManager.start', key);
// console.log('Phaser.StateManager.start', key);
// console.log(this);
// console.log(this.callbackContext);
@@ -212,7 +212,7 @@ Phaser.StateManager.prototype = {
if (this.game.isBooted == false)
{
console.log('Game is NOT booted, so set the requested state as pending');
// console.log('Game is NOT booted, so set the requested state as pending');
this._pendingState = key;
return;
}
@@ -243,14 +243,14 @@ Phaser.StateManager.prototype = {
if (this.onPreloadCallback)
{
console.log('Preload Callback found');
// console.log('Preload Callback found');
this.game.load.reset();
this.onPreloadCallback.call(this.callbackContext);
// Is the loader empty?
if (this.game.load.queueSize == 0)
{
console.log('Loader queue empty');
// console.log('Loader queue empty');
this.game.loadComplete();
if (this.onCreateCallback)
@@ -260,18 +260,18 @@ Phaser.StateManager.prototype = {
}
else
{
console.log('Loader started');
// console.log('Loader started');
// Start the loader going as we have something in the queue
this.game.load.start();
}
}
else
{
console.log('Preload callback not found');
// console.log('Preload callback not found');
// No init? Then there was nothing to load either
if (this.onCreateCallback)
{
console.log('Create callback found');
// console.log('Create callback found');
this.onCreateCallback.call(this.callbackContext);
}
@@ -343,10 +343,10 @@ Phaser.StateManager.prototype = {
loadComplete: function () {
console.log('Phaser.StateManager.loadComplete');
// console.log('Phaser.StateManager.loadComplete');
if (this.onCreateCallback) {
console.log('Create callback found');
// console.log('Create callback found');
this.onCreateCallback.call(this.callbackContext);
}
+16 -3
View File
@@ -1,13 +1,14 @@
Phaser.World = function (game) {
this.game = game;
this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height);
this._stage = new PIXI.Stage(0x000000);
this._container = new PIXI.DisplayObjectContainer();
this._stage.addChild(this._container);
this.bounds = new Phaser.Rectangle(0, 0, game.width, game.height);
};
@@ -18,8 +19,20 @@ Phaser.World.prototype = {
bounds: null,
add: function (sprite) {
this._container.addChild(sprite);
add: function (gameobject) {
this._container.addChild(gameobject);
},
addAt: function (gameobject, index) {
this._container.addChildAt(gameobject, index);
},
getAt: function (index) {
return this._container.getChildAt(index);
},
remove: function (gameobject) {
this._container.removeChild(gameobject);
},
/**