Group now extends PIXI.DisplayObjectContainer, rather than owning a _container property, which makes life a whole lot easier re: nesting.

This commit is contained in:
photonstorm
2014-02-06 02:31:36 +00:00
parent 9737710200
commit 4cfce8b4d2
89 changed files with 1176 additions and 1521 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
var Phaser = Phaser || {
VERSION: '<%= version %>',
DEV_VERSION: '1.1.5',
DEV_VERSION: '1.2',
GAMES: [],
AUTO: 0,
+1042 -1387
View File
File diff suppressed because it is too large Load Diff
+16 -71
View File
@@ -54,38 +54,28 @@ Phaser.World.prototype.boot = function () {
this.camera = new Phaser.Camera(this.game, 0, 0, 0, this.game.width, this.game.height);
this.camera.displayObject = this._container;
this.camera.displayObject = this;
this.game.camera = this.camera;
this.game.stage._stage.addChild(this);
}
/**
* This is called automatically after the plugins preUpdate and before the State.update.
* Most objects have preUpdate methods and it's where initial movement, drawing and calculations are done.
*
* @method Phaser.World#update
* @method Phaser.World#preUpdate
*/
Phaser.World.prototype.preUpdate = function () {
if (this.game.stage._stage.first._iNext)
for (var i = 0, len = this.children.length; i < len; i++)
{
var currentNode = this.game.stage._stage.first._iNext;
do
if (this.children[i]['preUpdate'])
{
// If preUpdate exists, and it returns false, skip PIXI child objects
if (currentNode['preUpdate'] && !currentNode.preUpdate())
{
currentNode = currentNode.last._iNext;
}
else
{
currentNode = currentNode._iNext;
}
this.children[i].preUpdate();
}
while (currentNode != this.game.stage._stage.last._iNext)
}
}
@@ -98,26 +88,12 @@ Phaser.World.prototype.preUpdate = function () {
*/
Phaser.World.prototype.update = function () {
this.currentRenderOrderID = 0;
if (this.game.stage._stage.first._iNext)
for (var i = 0, len = this.children.length; i < len; i++)
{
var currentNode = this.game.stage._stage.first._iNext;
do
if (this.children[i]['update'])
{
// If update exists, and it returns false, skip PIXI child objects
if (currentNode['update'] && !currentNode.update())
{
currentNode = currentNode.last._iNext;
}
else
{
currentNode = currentNode._iNext;
}
this.children[i].update();
}
while (currentNode != this.game.stage._stage.last._iNext)
}
}
@@ -138,40 +114,24 @@ Phaser.World.prototype.postUpdate = function () {
this.camera.update();
if (this.game.stage._stage.first._iNext)
for (var i = 0, len = this.children.length; i < len; i++)
{
var currentNode = this.game.stage._stage.first._iNext;
do
if (this.children[i]['postUpdate'])
{
if (currentNode['postUpdate'] && currentNode !== this.camera.target)
{
currentNode.postUpdate();
}
currentNode = currentNode._iNext;
this.children[i].postUpdate();
}
while (currentNode != this.game.stage._stage.last._iNext)
}
}
else
{
this.camera.update();
if (this.game.stage._stage.first._iNext)
for (var i = 0, len = this.children.length; i < len; i++)
{
var currentNode = this.game.stage._stage.first._iNext;
do
if (this.children[i]['postUpdate'])
{
if (currentNode['postUpdate'])
{
currentNode.postUpdate();
}
currentNode = currentNode._iNext;
this.children[i].postUpdate();
}
while (currentNode != this.game.stage._stage.last._iNext)
}
}
@@ -327,18 +287,3 @@ Object.defineProperty(Phaser.World.prototype, "randomY", {
});
/**
* @name Phaser.World#visible
* @property {boolean} visible - Gets or sets the visible state of the World.
*/
Object.defineProperty(Phaser.World.prototype, "visible", {
get: function () {
return this._container.visible;
},
set: function (value) {
this._container.visible = value;
}
});
-5
View File
@@ -85,11 +85,6 @@ Phaser.RenderTexture.prototype.render = function(displayObject, position, clear,
if (typeof clear === 'undefined') { clear = false; }
if (typeof renderHidden === 'undefined') { renderHidden = false; }
if (displayObject instanceof Phaser.Group)
{
displayObject = displayObject._container;
}
if (PIXI.gl)
{
this.renderWebGL(displayObject, position, clear, renderHidden);
+2 -2
View File
@@ -519,7 +519,6 @@ Phaser.Particles.Arcade.Emitter.prototype.at = function (object) {
* The emitters alpha value.
* @name Phaser.Particles.Arcade.Emitter#alpha
* @property {number} alpha - Gets or sets the alpha value of the Emitter.
*/
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "alpha", {
get: function () {
@@ -531,12 +530,12 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "alpha", {
}
});
*/
/**
* The emitter visible state.
* @name Phaser.Particles.Arcade.Emitter#visible
* @property {boolean} visible - Gets or sets the Emitter visible state.
*/
Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "visible", {
get: function () {
@@ -548,6 +547,7 @@ Object.defineProperty(Phaser.Particles.Arcade.Emitter.prototype, "visible", {
}
});
*/
/**
* @name Phaser.Particles.Arcade.Emitter#x
+9 -23
View File
@@ -636,15 +636,15 @@ Phaser.Physics.Arcade.prototype = {
return;
}
var len = group._container.children.length;
var len = group.children.length;
for (var i = 0; i < len; i++)
{
for (var j = i + 1; j <= len; j++)
{
if (group._container.children[i] && group._container.children[j] && group._container.children[i].exists && group._container.children[j].exists)
if (group.children[i] && group.children[j] && group.children[i].exists && group.children[j].exists)
{
this.collideSpriteVsSprite(group._container.children[i], group._container.children[j], collideCallback, processCallback, callbackContext, overlapOnly);
this.collideSpriteVsSprite(group.children[i], group.children[j], collideCallback, processCallback, callbackContext, overlapOnly);
}
}
}
@@ -664,19 +664,12 @@ Phaser.Physics.Arcade.prototype = {
return;
}
if (group1._container.first._iNext)
for (var i = 0, len = group1.children.length; i < len; i++)
{
var currentNode = group1._container.first._iNext;
do
if (group1.children[i].exists)
{
if (currentNode.exists)
{
this.collideSpriteVsGroup(currentNode, group2, collideCallback, processCallback, callbackContext, overlapOnly);
}
currentNode = currentNode._iNext;
this.collideSpriteVsGroup(group1.children[i], group2, collideCallback, processCallback, callbackContext, overlapOnly);
}
while (currentNode != group1._container.last._iNext);
}
},
@@ -746,19 +739,12 @@ Phaser.Physics.Arcade.prototype = {
return;
}
if (group._container.first._iNext)
for (var i = 0, len = group.children.length; i < len; i++)
{
var currentNode = group._container.first._iNext;
do
if (group.children[i].exists)
{
if (currentNode.exists)
{
this.collideSpriteVsTilemapLayer(currentNode, tilemapLayer, collideCallback, processCallback, callbackContext);
}
currentNode = currentNode._iNext;
this.collideSpriteVsTilemapLayer(group.children[i], tilemapLayer, collideCallback, processCallback, callbackContext);
}
while (currentNode != group._container.last._iNext);
}
},