From aff7d99a8a6af5baa4fb98792781b05cdd33ac8d Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Fri, 9 Aug 2013 20:03:36 +0100 Subject: [PATCH] Fixed bug where children of Groups wouldn't have their preUpdate methods called. --- Phaser/Phaser.csproj | 2 +- Phaser/core/Group.ts | 11 ++++++++++- Phaser/input/InputHandler.ts | 2 ++ Phaser/utils/DebugUtils.ts | 6 ++++++ Tests/phaser-debug.js | 13 +++++++++---- build/phaser-debug.js | 13 +++++++++---- 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Phaser/Phaser.csproj b/Phaser/Phaser.csproj index 988882f1..f802d96c 100644 --- a/Phaser/Phaser.csproj +++ b/Phaser/Phaser.csproj @@ -2,7 +2,7 @@ Debug - {BB30C59B-5B34-4F7C-B5CC-8D49EA280EDA} + {A90BE60F-CAEA-4747-904A-CDB097BA2459} {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library bin diff --git a/Phaser/core/Group.ts b/Phaser/core/Group.ts index 2ddc9d8d..103f7f4a 100644 --- a/Phaser/core/Group.ts +++ b/Phaser/core/Group.ts @@ -14,6 +14,7 @@ module Phaser { this.game = game; this.type = Phaser.Types.GROUP; + this.active = true; this.exists = true; this.visible = true; @@ -114,6 +115,11 @@ module Phaser { */ public exists: boolean; + /** + * If this Group exists or not. Can be set to false to skip certain loop checks. + */ + public active: boolean; + /** * Controls if this Group (and all of its contents) are rendered or skipped during the core game loop. */ @@ -184,7 +190,10 @@ module Phaser { if (this._member != null && this._member.exists && this._member.active) { - this._member.preUpdate(); + if (this._member.type != Phaser.Types.GROUP) + { + this._member.preUpdate(); + } this._member.update(); } } diff --git a/Phaser/input/InputHandler.ts b/Phaser/input/InputHandler.ts index a6d1a3aa..960e01f2 100644 --- a/Phaser/input/InputHandler.ts +++ b/Phaser/input/InputHandler.ts @@ -550,6 +550,7 @@ module Phaser.Components { * @param boundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here */ public enableDrag(lockCenter: boolean = false, bringToTop: boolean = false, pixelPerfect: boolean = false, alphaThreshold: number = 255, boundsRect: Rectangle = null, boundsSprite: Phaser.Sprite = null) { + this._dragPoint = new Point; this.draggable = true; @@ -569,6 +570,7 @@ module Phaser.Components { { this.boundsSprite = boundsSprite; } + } /** diff --git a/Phaser/utils/DebugUtils.ts b/Phaser/utils/DebugUtils.ts index 57e9fffc..885eb969 100644 --- a/Phaser/utils/DebugUtils.ts +++ b/Phaser/utils/DebugUtils.ts @@ -217,6 +217,12 @@ module Phaser { } + static renderSpriteWorldViewBounds(sprite: Phaser.Sprite, color: string = 'rgba(0,255,0,0.3)') { + + Phaser.DebugUtils.renderRectangle(sprite.worldView, color); + + } + /** * Render debug infos. (including name, bounds info, position and some other properties) * @param x {number} X position of the debug info to be rendered. diff --git a/Tests/phaser-debug.js b/Tests/phaser-debug.js index d352586f..1b6c7f4c 100644 --- a/Tests/phaser-debug.js +++ b/Tests/phaser-debug.js @@ -15085,6 +15085,10 @@ var Phaser; * Pre-update is called right before update() on each object in the game loop. */ Sprite.prototype.preUpdate = function () { + if (this.name == 'piece1') { + console.log('wv', this.worldView); + } + this.transform.update(); if (this.transform.scrollFactor.x != 1 && this.transform.scrollFactor.x != 0) { @@ -18110,6 +18114,11 @@ var Phaser; Phaser.DebugUtils.line('bottom: ' + sprite.worldView.bottom + ' right: ' + sprite.worldView.right.toFixed(1)); }; + DebugUtils.renderSpriteWorldViewBounds = function (sprite, color) { + if (typeof color === "undefined") { color = 'rgba(0,255,0,0.3)'; } + Phaser.DebugUtils.renderRectangle(sprite.worldView, color); + }; + DebugUtils.renderSpriteInfo = /** * Render debug infos. (including name, bounds info, position and some other properties) * @param x {number} X position of the debug info to be rendered. @@ -19789,10 +19798,6 @@ var Phaser; } }; - Game.prototype.emptyCallback = function () { - // Called by onUpdateCallback etc - }; - /** * Game loop method will be called when it's running. */ diff --git a/build/phaser-debug.js b/build/phaser-debug.js index d352586f..1b6c7f4c 100644 --- a/build/phaser-debug.js +++ b/build/phaser-debug.js @@ -15085,6 +15085,10 @@ var Phaser; * Pre-update is called right before update() on each object in the game loop. */ Sprite.prototype.preUpdate = function () { + if (this.name == 'piece1') { + console.log('wv', this.worldView); + } + this.transform.update(); if (this.transform.scrollFactor.x != 1 && this.transform.scrollFactor.x != 0) { @@ -18110,6 +18114,11 @@ var Phaser; Phaser.DebugUtils.line('bottom: ' + sprite.worldView.bottom + ' right: ' + sprite.worldView.right.toFixed(1)); }; + DebugUtils.renderSpriteWorldViewBounds = function (sprite, color) { + if (typeof color === "undefined") { color = 'rgba(0,255,0,0.3)'; } + Phaser.DebugUtils.renderRectangle(sprite.worldView, color); + }; + DebugUtils.renderSpriteInfo = /** * Render debug infos. (including name, bounds info, position and some other properties) * @param x {number} X position of the debug info to be rendered. @@ -19789,10 +19798,6 @@ var Phaser; } }; - Game.prototype.emptyCallback = function () { - // Called by onUpdateCallback etc - }; - /** * Game loop method will be called when it's running. */