mirror of
https://github.com/wassname/phaser.git
synced 2026-08-05 13:21:00 +08:00
Fixed issue where Image, Sprite, etc wouldn't call preUpdate or postUpdate of its children.
Fixed issue where renderOrderID wasn't being assigned correctly, causing the Input Handler to be unable to select the "top" item on a display list (would all default to zero) Fixed issue where Stage would assign renderOrderIDs in reverse, should be in sequence. Fixed issue where objects where checking World for the currentRenderOrderID by mistake instead of Stage. Basically, input handling works a lot better now for Groups and nested objects :)
This commit is contained in:
+8
-2
@@ -55,6 +55,11 @@ Phaser.Stage = function (game, width, height) {
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
/**
|
||||
* @property {number} currentRenderOrderID - Reset each frame, keeps a count of the total number of objects updated.
|
||||
*/
|
||||
this.currentRenderOrderID = 0;
|
||||
|
||||
/**
|
||||
* @property {string} hiddenVar - The page visibility API event name.
|
||||
* @private
|
||||
@@ -98,9 +103,10 @@ Phaser.Stage.prototype.preUpdate = function () {
|
||||
|
||||
this.currentRenderOrderID = 0;
|
||||
|
||||
var i = this.children.length;
|
||||
// This can't loop in reverse, we need the orderID to be in sequence
|
||||
var len = this.children.length;
|
||||
|
||||
while (i--)
|
||||
for (var i = 0; i < len; i++)
|
||||
{
|
||||
this.children[i].preUpdate();
|
||||
}
|
||||
|
||||
@@ -33,11 +33,6 @@ Phaser.World = function (game) {
|
||||
* @property {Phaser.Camera} camera - Camera instance.
|
||||
*/
|
||||
this.camera = null;
|
||||
|
||||
/**
|
||||
* @property {number} currentRenderOrderID - Reset each frame, keeps a count of the total number of objects updated.
|
||||
*/
|
||||
this.currentRenderOrderID = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ Phaser.BitmapText.prototype.preUpdate = function () {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
this._cache[3] = this.game.world.currentRenderOrderID++;
|
||||
this._cache[3] = this.game.stage.currentRenderOrderID++;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -102,7 +102,7 @@ Phaser.Graphics.prototype.preUpdate = function () {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
this._cache[3] = this.game.world.currentRenderOrderID++;
|
||||
this._cache[3] = this.game.stage.currentRenderOrderID++;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -134,7 +134,7 @@ Phaser.Image.prototype.preUpdate = function() {
|
||||
|
||||
if (!this.exists || !this.parent.exists)
|
||||
{
|
||||
this.renderOrderID = -1;
|
||||
this._cache[3] = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,13 @@ Phaser.Image.prototype.preUpdate = function() {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
this._cache[3] = this.game.world.currentRenderOrderID++;
|
||||
this._cache[3] = this.game.stage.currentRenderOrderID++;
|
||||
}
|
||||
|
||||
// Update any Children
|
||||
for (var i = 0, len = this.children.length; i < len; i++)
|
||||
{
|
||||
this.children[i].preUpdate();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -185,6 +191,12 @@ Phaser.Image.prototype.postUpdate = function() {
|
||||
this.position.y = this.game.camera.view.y + this.cameraOffset.y;
|
||||
}
|
||||
|
||||
// Update any Children
|
||||
for (var i = 0, len = this.children.length; i < len; i++)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -257,14 +257,15 @@ Phaser.Sprite.prototype.preUpdate = function() {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
this._cache[3] = this.game.world.currentRenderOrderID++;
|
||||
this._cache[3] = this.game.stage.currentRenderOrderID++;
|
||||
}
|
||||
|
||||
this.animations.update();
|
||||
|
||||
if (this.body)
|
||||
// Update any Children
|
||||
for (var i = 0, len = this.children.length; i < len; i++)
|
||||
{
|
||||
// this.body.preUpdate();
|
||||
this.children[i].preUpdate();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -273,6 +274,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
|
||||
|
||||
/**
|
||||
* Override and use this function in your own custom objects to handle any update requirements you may have.
|
||||
* Remember if this Sprite has any children you should call update on them too.
|
||||
*
|
||||
* @method Phaser.Sprite#update
|
||||
* @memberof Phaser.Sprite
|
||||
@@ -309,6 +311,12 @@ Phaser.Sprite.prototype.postUpdate = function() {
|
||||
this.position.y = this.game.camera.view.y + this.cameraOffset.y;
|
||||
}
|
||||
|
||||
// Update any Children
|
||||
for (var i = 0, len = this.children.length; i < len; i++)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+13
-1
@@ -148,7 +148,13 @@ Phaser.Text.prototype.preUpdate = function () {
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
this._cache[3] = this.game.world.currentRenderOrderID++;
|
||||
this._cache[3] = this.game.stage.currentRenderOrderID++;
|
||||
}
|
||||
|
||||
// Update any Children
|
||||
for (var i = 0, len = this.children.length; i < len; i++)
|
||||
{
|
||||
this.children[i].preUpdate();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -177,6 +183,12 @@ Phaser.Text.prototype.postUpdate = function () {
|
||||
this.position.y = this.game.camera.view.y + this.cameraOffset.y;
|
||||
}
|
||||
|
||||
// Update any Children
|
||||
for (var i = 0, len = this.children.length; i < len; i++)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,6 +140,17 @@ Phaser.TileSprite.prototype.preUpdate = function() {
|
||||
this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed;
|
||||
}
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
this._cache[3] = this.game.stage.currentRenderOrderID++;
|
||||
}
|
||||
|
||||
// Update any Children
|
||||
for (var i = 0, len = this.children.length; i < len; i++)
|
||||
{
|
||||
this.children[i].preUpdate();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -169,6 +180,12 @@ Phaser.TileSprite.prototype.postUpdate = function() {
|
||||
this.position.y = this.game.camera.view.y + this.cameraOffset.y;
|
||||
}
|
||||
|
||||
// Update any Children
|
||||
for (var i = 0, len = this.children.length; i < len; i++)
|
||||
{
|
||||
this.children[i].postUpdate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -355,7 +355,7 @@ Phaser.Pointer.prototype = {
|
||||
}
|
||||
|
||||
// Work out which object is on the top
|
||||
this._highestRenderOrderID = -1;
|
||||
this._highestRenderOrderID = Number.MAX_SAFE_INTEGER;
|
||||
this._highestRenderObject = null;
|
||||
this._highestInputPriorityID = -1;
|
||||
|
||||
@@ -367,11 +367,11 @@ Phaser.Pointer.prototype = {
|
||||
do
|
||||
{
|
||||
// If the object is using pixelPerfect checks, or has a higher InputManager.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top
|
||||
if (currentNode.pixelPerfectClick || currentNode.pixelPerfectOver || currentNode.priorityID > this._highestInputPriorityID || (currentNode.priorityID === this._highestInputPriorityID && currentNode.sprite.renderOrderID > this._highestRenderOrderID))
|
||||
if (currentNode.pixelPerfectClick || currentNode.pixelPerfectOver || currentNode.priorityID > this._highestInputPriorityID || (currentNode.priorityID === this._highestInputPriorityID && currentNode.sprite._cache[3] < this._highestRenderOrderID))
|
||||
{
|
||||
if ((!fromClick && currentNode.checkPointerOver(this)) || (fromClick && currentNode.checkPointerDown(this)))
|
||||
{
|
||||
this._highestRenderOrderID = currentNode.sprite.renderOrderID;
|
||||
this._highestRenderOrderID = currentNode.sprite._cache[3]; // renderOrderID
|
||||
this._highestInputPriorityID = currentNode.priorityID;
|
||||
this._highestRenderObject = currentNode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user