State swap example done and working.

This commit is contained in:
Richard Davey
2013-09-13 05:44:04 +01:00
parent fd0a071cb3
commit 7c6e6df91a
13 changed files with 282 additions and 11 deletions
+9 -1
View File
@@ -686,9 +686,17 @@ Phaser.Group.prototype = {
removeAll: function () {
if (this._container.children.length == 0)
{
return;
}
do
{
this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0], this);
if (this._container.children[0].events)
{
this._container.children[0].events.onRemovedFromGroup.dispatch(this._container.children[0], this);
}
this._container.removeChild(this._container.children[0]);
}
while (this._container.children.length > 0);
+6 -1
View File
@@ -73,11 +73,16 @@ Phaser.LinkedList.prototype = {
callAll: function (callback) {
if (!this.first || !this.last)
{
return;
}
var entity = this.first;
do
{
if (entity[callback])
if (entity && entity[callback])
{
entity[callback].call(entity);
}
+3 -3
View File
@@ -1,7 +1,7 @@
/**
* State
*
* This is a base State class which can be extended if you are creating your game with TypeScript.
* This is a base State class which can be extended if you are creating your own game.
* It provides quick access to common functions such as the camera, cache, input, match, sound and more.
*
* @package Phaser.State
@@ -18,7 +18,7 @@ Phaser.State = function () {
this.cache = null;
this.input = null;
this.load = null;
// this.math = null;
this.math = null;
this.sound = null;
this.stage = null;
this.time = null;
@@ -39,7 +39,7 @@ Phaser.State.prototype = {
this.cache = game.cache;
this.input = game.input;
this.load = game.load;
// this.math = game.math;
this.math = game.math;
this.sound = game.sound;
this.stage = game.stage;
this.time = game.time;
+4 -2
View File
@@ -151,6 +151,7 @@ Phaser.StateManager.prototype = {
{
// console.log('Phaser.StateManager.addState: Object given');
newState = state;
newState.game = this.game;
}
else if (typeof state === 'function')
{
@@ -237,9 +238,10 @@ Phaser.StateManager.prototype = {
if (clearWorld) {
//this.game.world.destroy();
this.game.world.destroy();
if (clearCache == true) {
if (clearCache == true)
{
this.game.cache.destroy();
}
}
+15 -1
View File
@@ -107,7 +107,21 @@ Phaser.World.prototype = {
this.bounds.height = height;
}
}
},
/**
* Destroyer of worlds.
*/
destroy: function () {
this.camera.x = 0;
this.camera.y = 0;
this.game.input.reset(true);
this.group.removeAll();
}
};
+6 -1
View File
@@ -5,6 +5,9 @@ Phaser.Text = function (game, x, y, text, style) {
text = text || '';
style = style || '';
PIXI.Text.call(this, text, style);
/*
this.canvas = document.createElement("canvas");
this.context = this.canvas.getContext("2d");
@@ -21,10 +24,12 @@ Phaser.Text = function (game, x, y, text, style) {
this.updateText();
this.dirty = false;
*/
};
Phaser.Text.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Text.prototype);
// Phaser.Text.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Text.prototype);
Phaser.Text.prototype = Phaser.Utils.extend(true, PIXI.Text.prototype);
Phaser.Text.prototype.constructor = Phaser.Text;
// Add our own custom methods
+1 -1
View File
@@ -378,7 +378,7 @@ Phaser.Input.prototype = {
**/
reset: function (hard) {
hard = hard || false;
if (typeof hard == 'undefined') { hard = false; }
this.keyboard.reset();
this.mousePointer.reset();