Skip to content

Commit aff7d99

Browse files
committed
Fixed bug where children of Groups wouldn't have their preUpdate methods called.
1 parent 0b1bcaf commit aff7d99

6 files changed

Lines changed: 37 additions & 10 deletions

File tree

Phaser/Phaser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<ProjectGuid>{BB30C59B-5B34-4F7C-B5CC-8D49EA280EDA}</ProjectGuid>
5+
<ProjectGuid>{A90BE60F-CAEA-4747-904A-CDB097BA2459}</ProjectGuid>
66
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
77
<OutputType>Library</OutputType>
88
<OutputPath>bin</OutputPath>

Phaser/core/Group.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module Phaser {
1414

1515
this.game = game;
1616
this.type = Phaser.Types.GROUP;
17+
this.active = true;
1718
this.exists = true;
1819
this.visible = true;
1920

@@ -114,6 +115,11 @@ module Phaser {
114115
*/
115116
public exists: boolean;
116117

118+
/**
119+
* If this Group exists or not. Can be set to false to skip certain loop checks.
120+
*/
121+
public active: boolean;
122+
117123
/**
118124
* Controls if this Group (and all of its contents) are rendered or skipped during the core game loop.
119125
*/
@@ -184,7 +190,10 @@ module Phaser {
184190

185191
if (this._member != null && this._member.exists && this._member.active)
186192
{
187-
this._member.preUpdate();
193+
if (this._member.type != Phaser.Types.GROUP)
194+
{
195+
this._member.preUpdate();
196+
}
188197
this._member.update();
189198
}
190199
}

Phaser/input/InputHandler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ module Phaser.Components {
550550
* @param boundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here
551551
*/
552552
public enableDrag(lockCenter: boolean = false, bringToTop: boolean = false, pixelPerfect: boolean = false, alphaThreshold: number = 255, boundsRect: Rectangle = null, boundsSprite: Phaser.Sprite = null) {
553+
553554
this._dragPoint = new Point;
554555

555556
this.draggable = true;
@@ -569,6 +570,7 @@ module Phaser.Components {
569570
{
570571
this.boundsSprite = boundsSprite;
571572
}
573+
572574
}
573575

574576
/**

Phaser/utils/DebugUtils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ module Phaser {
217217

218218
}
219219

220+
static renderSpriteWorldViewBounds(sprite: Phaser.Sprite, color: string = 'rgba(0,255,0,0.3)') {
221+
222+
Phaser.DebugUtils.renderRectangle(sprite.worldView, color);
223+
224+
}
225+
220226
/**
221227
* Render debug infos. (including name, bounds info, position and some other properties)
222228
* @param x {number} X position of the debug info to be rendered.

Tests/phaser-debug.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15085,6 +15085,10 @@ var Phaser;
1508515085
* Pre-update is called right before update() on each object in the game loop.
1508615086
*/
1508715087
Sprite.prototype.preUpdate = function () {
15088+
if (this.name == 'piece1') {
15089+
console.log('wv', this.worldView);
15090+
}
15091+
1508815092
this.transform.update();
1508915093

1509015094
if (this.transform.scrollFactor.x != 1 && this.transform.scrollFactor.x != 0) {
@@ -18110,6 +18114,11 @@ var Phaser;
1811018114
Phaser.DebugUtils.line('bottom: ' + sprite.worldView.bottom + ' right: ' + sprite.worldView.right.toFixed(1));
1811118115
};
1811218116

18117+
DebugUtils.renderSpriteWorldViewBounds = function (sprite, color) {
18118+
if (typeof color === "undefined") { color = 'rgba(0,255,0,0.3)'; }
18119+
Phaser.DebugUtils.renderRectangle(sprite.worldView, color);
18120+
};
18121+
1811318122
DebugUtils.renderSpriteInfo = /**
1811418123
* Render debug infos. (including name, bounds info, position and some other properties)
1811518124
* @param x {number} X position of the debug info to be rendered.
@@ -19789,10 +19798,6 @@ var Phaser;
1978919798
}
1979019799
};
1979119800

19792-
Game.prototype.emptyCallback = function () {
19793-
// Called by onUpdateCallback etc
19794-
};
19795-
1979619801
/**
1979719802
* Game loop method will be called when it's running.
1979819803
*/

build/phaser-debug.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15085,6 +15085,10 @@ var Phaser;
1508515085
* Pre-update is called right before update() on each object in the game loop.
1508615086
*/
1508715087
Sprite.prototype.preUpdate = function () {
15088+
if (this.name == 'piece1') {
15089+
console.log('wv', this.worldView);
15090+
}
15091+
1508815092
this.transform.update();
1508915093

1509015094
if (this.transform.scrollFactor.x != 1 && this.transform.scrollFactor.x != 0) {
@@ -18110,6 +18114,11 @@ var Phaser;
1811018114
Phaser.DebugUtils.line('bottom: ' + sprite.worldView.bottom + ' right: ' + sprite.worldView.right.toFixed(1));
1811118115
};
1811218116

18117+
DebugUtils.renderSpriteWorldViewBounds = function (sprite, color) {
18118+
if (typeof color === "undefined") { color = 'rgba(0,255,0,0.3)'; }
18119+
Phaser.DebugUtils.renderRectangle(sprite.worldView, color);
18120+
};
18121+
1811318122
DebugUtils.renderSpriteInfo = /**
1811418123
* Render debug infos. (including name, bounds info, position and some other properties)
1811518124
* @param x {number} X position of the debug info to be rendered.
@@ -19789,10 +19798,6 @@ var Phaser;
1978919798
}
1979019799
};
1979119800

19792-
Game.prototype.emptyCallback = function () {
19793-
// Called by onUpdateCallback etc
19794-
};
19795-
1979619801
/**
1979719802
* Game loop method will be called when it's running.
1979819803
*/

0 commit comments

Comments
 (0)