Skip to content

Commit 45b6d5a

Browse files
committed
Removed: Debug.renderSpriteTouching, Debug.renderLocalTransformInfo, Debug.renderWorldTransformInfo, Debug.renderSpriteCollision and Debug.dumpLinkedList.
Debug.renderPhysicsBody(body, color) is extremely useful for debugging the new physics bodies. Will draw the outline + points in the color given. Debug.renderBodyInfo(sprite, x, y, color) will display lots of Sprite body data.
1 parent 13a8676 commit 45b6d5a

10 files changed

Lines changed: 183 additions & 510 deletions

File tree

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Significant API changes:
7272
* Removed Body.deltaAbsX and deltaAbsY as they are no longer used internally.
7373
* Body.screenX and screenY moved to getters, no longer calculated every frame.
7474
* ArcadePhysics now has setBounds and setBoundsToWorld, and you can specify which walls are created or not (left, right, up, down)
75+
* Removed: Debug.renderSpriteTouching, Debug.renderLocalTransformInfo, Debug.renderWorldTransformInfo, Debug.renderSpriteCollision and Debug.dumpLinkedList.
7576

7677

7778
New features:
@@ -91,7 +92,7 @@ New features:
9192
* Group.set will let you deep set a new propery on a single child of the Group.
9293
* Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation)
9394
* Added Ejecta detection to Device (thanks endel)
94-
* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value, or '-400'.
95+
* Tweens can now work with relative + and - values. You can do: `tween(sprite).to( { x: '+400' })` and it will add 400 to the current sprite.x value.
9596
* Buttons now properly use their upFrame if set.
9697
* InputHandler now has snapOffsetX and snapOffsetY properties so your snap grid doesn't have to be 0,0 aligned (thanks srmeier)
9798
* Loader.progressFloat contains the actual non-rounded progress value, where-as Loader.progress contains a rounded value. Use progressFloat if you've > 100 files to load.
@@ -111,12 +112,15 @@ New features:
111112
* Math.normalizeAngle - normalises an angle, now in radians only.
112113
* Math.normalizeLatitude - Normalizes a latitude to the [-90,90] range.
113114
* Math.normalizeLongitude - Normalizes a longitude to the [-180,180] range.
114-
* Phaser.Line added to the group of geometry classes, with full point on line/segment and intersection tests (see new examples)
115+
* Phaser.Line added to the geometry classes, with full point on line/segment and intersection tests (see new examples)
115116
* Phaser.CANVAS_PX_ROUND is a boolean. If 'true' the Canvas renderer will Math.floor() all coordinates before drawImage, stopping pixel interpolation. Defaults to false.
116117
* Phaser.CANVAS_CLEAR_RECT is a boolean. If 'true' (the default) it will context.clearRect() every frame. If false this is skipped (useful if you know you don't need it)
117118
* Collision now works between Sprites positioned via sprite.x/y, sprite.body.x/y or sprite.body.velocity.
118119
* If you are tweening a sprite and still want physics collision, set `sprite.body.moves = false` otherwise it will fight against the tween motion.
119-
120+
* Game.enableStep will enable core game loop stepping. When enabled you must call game.step() directly (perhaps via a DOM button?), very useful for debugging!
121+
* Game.disableStep turns core update loop stepping off.
122+
* Debug.renderPhysicsBody(body, color) is extremely useful for debugging the new physics bodies. Will draw the outline + points in the color given.
123+
* Debug.renderBodyInfo(sprite, x, y, color) will display lots of Sprite body data.
120124

121125

122126
New Examples:

examples/wip/rabbit map.js

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,20 @@ console.log(' --- state create start ---');
5454

5555
layer.resizeWorld();
5656

57-
// game.physics.gravity.y = 200;
57+
game.physics.gravity.y = 200;
5858

5959

60-
sprite = game.add.sprite(100, 180, 'phaser');
61-
sprite.body.moves = false;
60+
sprite = game.add.sprite(100, 240, 'phaser');
61+
// sprite.anchor.setTo(0.5, 0.5);
62+
// sprite.body.setCircle(20);
63+
64+
// sprite.body.moves = false;
6265

6366
ball = game.add.sprite(200, 180, 'ball');
6467

65-
game.add.tween(sprite).to({x: 500},5000,Phaser.Easing.Linear.None,true);
68+
// game.add.tween(sprite).to({x: 500},5000,Phaser.Easing.Linear.None,true);
69+
70+
// game.add.tween(sprite).to({angle: 360},5000,Phaser.Easing.Linear.None,true);
6671

6772
// sprite = game.add.sprite(200, 240, 'phaser'); // 3-block corner test
6873

@@ -74,7 +79,9 @@ console.log(' --- state create start ---');
7479
// sprite.body.velocity.y = 200;
7580

7681

77-
// sprite.anchor.setTo(0.5, 0.5);
82+
83+
84+
7885

7986
// We'll set a lower max angular velocity here to keep it from going totally nuts
8087
// sprite.body.maxAngular = 500;
@@ -83,7 +90,7 @@ console.log(' --- state create start ---');
8390
// sprite.body.angularDrag = 50;
8491

8592
// sprite.body.bounce.x = 0.8;
86-
// sprite.body.bounce.y = 0.8;
93+
sprite.body.bounce.y = 0.8;
8794

8895
// sprite.angle = 35;
8996

@@ -124,14 +131,17 @@ function update() {
124131

125132
// sprite.body.velocity.y = -300;
126133

134+
// sprite.body.angularVelocity = -100;
135+
// sprite.body.angularAcceleration = 200;
136+
137+
127138
// sprite.body.velocity.x = 0;
128139
// sprite.body.velocity.y = 0;
129140
// sprite.body.angularVelocity = 0;
130141

131142
// sprite.body.acceleration.x = 0;
132143
// sprite.body.angularAcceleration = 0;
133144

134-
/*
135145
if (cursors.left.isDown)
136146
{
137147
// sprite.body.acceleration.x = -200;
@@ -149,11 +159,6 @@ function update() {
149159
{
150160
game.physics.velocityFromAngle(sprite.angle, 300, sprite.body.velocity);
151161
}
152-
else
153-
{
154-
// game.physics.velocityFromAngle(sprite.angle, sprite.body.velocity, sprite.body.velocity);
155-
}
156-
*/
157162

158163

159164

@@ -201,23 +206,23 @@ function update() {
201206
// sprite.x += 2;
202207
// }
203208

204-
if (cursors.up.isDown)
205-
{
206-
sprite.body.y -= 2;
207-
}
208-
else if (cursors.down.isDown)
209-
{
210-
sprite.body.y += 2;
211-
}
209+
// if (cursors.up.isDown)
210+
// {
211+
// sprite.body.y -= 2;
212+
// }
213+
// else if (cursors.down.isDown)
214+
// {
215+
// sprite.body.y += 2;
216+
// }
212217

213-
if (cursors.left.isDown)
214-
{
215-
sprite.body.x -= 2;
216-
}
217-
else if (cursors.right.isDown)
218-
{
219-
sprite.body.x += 2;
220-
}
218+
// if (cursors.left.isDown)
219+
// {
220+
// sprite.body.x -= 2;
221+
// }
222+
// else if (cursors.right.isDown)
223+
// {
224+
// sprite.body.x += 2;
225+
// }
221226

222227

223228

@@ -228,7 +233,7 @@ function render() {
228233
// game.debug.renderSpriteBody(sprite);
229234
// game.debug.renderSpriteBounds(sprite);
230235

231-
// game.debug.renderPhysicsBody(sprite.body);
236+
game.debug.renderPhysicsBody(sprite.body);
232237
game.debug.renderBodyInfo(sprite, 32, 32);
233238

234239
// game.debug.renderLine(marker, 'rgba(255,255,255,0.5)');

src/core/Game.js

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,27 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
226226
*/
227227
this.particles = null;
228228

229+
/**
230+
* @property {boolean} stepping - Enable core loop stepping with Game.enableStep().
231+
* @default
232+
* @readonly
233+
*/
234+
this.stepping = false;
235+
236+
/**
237+
* @property {boolean} stepping - An internal property used by enableStep, but also useful to query from your own game objects.
238+
* @default
239+
* @readonly
240+
*/
241+
this.pendingStep = false;
242+
243+
/**
244+
* @property {number} stepCount - When stepping is enabled this contains the current step cycle.
245+
* @default
246+
* @readonly
247+
*/
248+
this.stepCount = 0;
249+
229250
// Parse the configuration object (if any)
230251
if (arguments.length === 1 && typeof arguments[0] === 'object')
231252
{
@@ -283,10 +304,6 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
283304
window.addEventListener('load', this._onBoot, false);
284305
}
285306

286-
this.pendingStep = false;
287-
this.stepping = false;
288-
this.stepCount = 0;
289-
290307
return this;
291308

292309
};
@@ -592,21 +609,17 @@ Phaser.Game.prototype = {
592609
}
593610

594611
this.plugins.preUpdate();
595-
// console.log('world preUpdate');
596612
this.world.preUpdate();
597613

598614
this.stage.update();
599615
this.input.update();
600616
this.tweens.update();
601617
this.sound.update();
602-
// console.log('state update');
603618
this.state.update();
604-
// console.log('world update');
605619
this.world.update();
606620
this.particles.update();
607621
this.plugins.update();
608622

609-
// console.log('world postUpdate');
610623
this.world.postUpdate();
611624
this.plugins.postUpdate();
612625
}
@@ -623,6 +636,12 @@ Phaser.Game.prototype = {
623636

624637
},
625638

639+
/**
640+
* Enable core game loop stepping. When enabled you must call game.step() directly (perhaps via a DOM button?)
641+
* Calling step will advance the game loop by one frame. This is extremely useful to hard to track down errors!
642+
*
643+
* @method Phaser.Game#enableStep
644+
*/
626645
enableStep: function () {
627646

628647
this.stepping = true;
@@ -631,12 +650,28 @@ Phaser.Game.prototype = {
631650

632651
},
633652

653+
/**
654+
* Disables core game loop stepping.
655+
*
656+
* @method Phaser.Game#disableStep
657+
*/
658+
disableStep: function () {
659+
660+
this.stepping = false;
661+
this.pendingStep = false;
662+
663+
},
664+
665+
/**
666+
* When stepping is enabled you must call this function directly (perhaps via a DOM button?) to advance the game loop by one frame.
667+
* This is extremely useful to hard to track down errors! Use the internal stepCount property to monitor progress.
668+
*
669+
* @method Phaser.Game#step
670+
*/
634671
step: function () {
635672

636673
this.pendingStep = false;
637674
this.stepCount++;
638-
console.log('');
639-
console.log('----------------------------- Game step', this.stepCount);
640675

641676
},
642677

src/gameobjects/Sprite.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,10 @@ Phaser.Sprite = function (game, x, y, key, frame) {
373373
this.updateCache();
374374
this.updateBounds();
375375

376-
this.debug = false;
377-
378376
/**
379377
* @property {PIXI.Point} pivot - The pivot point of the displayObject that it rotates around.
380378
*/
381379

382-
383380
};
384381

385382
// Needed to keep the PIXI.Sprite constructor in the prototype chain (as the core pixi renderer uses an instanceof check sadly)
@@ -394,11 +391,6 @@ Phaser.Sprite.prototype.constructor = Phaser.Sprite;
394391
*/
395392
Phaser.Sprite.prototype.preUpdate = function() {
396393

397-
if (this.debug)
398-
{
399-
console.log('Sprite preUpdate xy: ', this.x, this.y, 'wxy:', this.world.x, this.world.y);
400-
}
401-
402394
if (!this.exists || (this.group && !this.group.exists))
403395
{
404396
this.renderOrderID = -1;
@@ -706,12 +698,6 @@ Phaser.Sprite.prototype.postUpdate = function() {
706698

707699
this.position.x = this._cache.x;
708700
this.position.y = this._cache.y;
709-
710-
if (this.debug)
711-
{
712-
console.log('Sprite postUpdate xy: ', this.x, this.y, 'right:', this.right);
713-
}
714-
715701
}
716702

717703
};

src/geom/Line.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ Phaser.Line.prototype = {
5454

5555
},
5656

57+
/**
58+
* Sets the line to match the x/y coordinates of the two given sprites.
59+
* Can optionally be calculated from their center coordinates.
60+
* @method Phaser.Line#fromSprite
61+
* @param {Phaser.Sprite} startSprite - The coordinates of this Sprite will be set to the Line.start point.
62+
* @param {Phaser.Sprite} endSprite - The coordinates of this Sprite will be set to the Line.start point.
63+
* @param {boolean} [useCenter=true] - If true it will use startSprite.center.x, if false startSprite.x.
64+
*/
5765
fromSprite: function (startSprite, endSprite, useCenter) {
5866

5967
if (typeof useCenter === 'undefined') { useCenter = true; }

src/physics/arcade/ArcadePhysics.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ Phaser.Physics.Arcade = function (game) {
9999
*/
100100
this._angle = 0;
101101

102+
/**
103+
* @property {number} _drag - Internal cache var.
104+
* @private
105+
*/
106+
this._drag = 0;
107+
102108
/**
103109
* @property {number} _dx - Internal cache var.
104110
* @private
@@ -376,7 +382,8 @@ Phaser.Physics.Arcade.prototype = {
376382

377383
if (body.sprite.debug)
378384
{
379-
console.log('updateMotion: acx', body.acceleration.x, 'acy', body.acceleration.y, 'gravx', this._gravityX, 'gravy', this._gravityY, 'elapsed', this.game.time.physicsElapsed);
385+
// console.log('updateMotion: acx', body.acceleration.x, 'acy', body.acceleration.y, 'gravx', this._gravityX, 'gravy', this._gravityY, 'elapsed', this.game.time.physicsElapsed);
386+
console.log('updateMotion: rotation', body.rotation, 'vd', this._velocityDelta, 'drag', this._drag, 'acceleration', body.angularAcceleration);
380387
}
381388

382389
this._p.setTo((body.acceleration.x + this._gravityX) * this.game.time.physicsElapsed, (body.acceleration.y + this._gravityY) * this.game.time.physicsElapsed);

0 commit comments

Comments
 (0)