mirror of
https://github.com/wassname/phaser.git
synced 2026-07-19 11:26:26 +08:00
And we have level/ground jitter fixed :) Starstruck is running again properly now too. Time to commit and remove lots of debug data.
This commit is contained in:
@@ -377,8 +377,6 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
||||
*/
|
||||
this.debug = false;
|
||||
|
||||
// this.events.onAddedToGroup.add(this.initGroup, this);
|
||||
|
||||
this.updateCache();
|
||||
this.updateBounds();
|
||||
|
||||
@@ -430,12 +428,6 @@ Phaser.Sprite.prototype.preUpdate = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.debug)
|
||||
{
|
||||
console.log('Sprite preUpdate', this.parent.worldTransform[2], this.parent.worldTransform[5], 'LT', this.parent.localTransform[2], this.parent.localTransform[5], 'xy', this.parent.position.x, this.parent.position.y);
|
||||
console.log('Sprite preUpdate', this.x, this.y, 'world', this.world.x, this.world.y);
|
||||
}
|
||||
|
||||
if (!this.exists || (this.group && !this.group.exists))
|
||||
{
|
||||
this.renderOrderID = -1;
|
||||
@@ -494,11 +486,6 @@ Phaser.Sprite.prototype.updateCache = function() {
|
||||
this._cache.prevX = this.world.x;
|
||||
this._cache.prevY = this.world.y;
|
||||
|
||||
if (this.debug)
|
||||
{
|
||||
console.log('Sprite updateCache', this._cache.prevX, this._cache.prevY);
|
||||
}
|
||||
|
||||
if (this.fixedToCamera)
|
||||
{
|
||||
this.x = this.game.camera.view.x + this.cameraOffset.x;
|
||||
@@ -724,16 +711,6 @@ Phaser.Sprite.prototype.postUpdate = function() {
|
||||
if (this.body)
|
||||
{
|
||||
this.body.postUpdate();
|
||||
|
||||
// console.log('Sprite postUpdate wt', this.worldTransform[2], this.worldTransform[5], 'xy', this.x, this.y);
|
||||
|
||||
// this._cache.x = this.x;
|
||||
// this._cache.y = this.y;
|
||||
|
||||
// this.position.x = this._cache.x;
|
||||
// this.position.y = this._cache.y;
|
||||
|
||||
// this.world.setTo(this.game.camera.x + this.worldTransform[2], this.game.camera.y + this.worldTransform[5]);
|
||||
}
|
||||
|
||||
if (this.fixedToCamera)
|
||||
@@ -747,16 +724,8 @@ Phaser.Sprite.prototype.postUpdate = function() {
|
||||
this._cache.y = this.y;
|
||||
}
|
||||
|
||||
// this.world.setTo(this.game.camera.x + this.worldTransform[2], this.game.camera.y + this.worldTransform[5]);
|
||||
|
||||
this.position.x = this._cache.x;
|
||||
this.position.y = this._cache.y;
|
||||
|
||||
if (this.debug)
|
||||
{
|
||||
console.log('Sprite postUpdate delta', this.deltaX, this.deltaY, 'prev', this._cache.prevX, this._cache.prevY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -183,7 +183,7 @@ Phaser.Physics.Arcade.prototype = {
|
||||
|
||||
if (!body.collideWorldBounds || (!this.worldLeft && !this.worldRight && !this.worldTop && !this.worldBottom))
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
this._response.clear();
|
||||
@@ -234,13 +234,13 @@ Phaser.Physics.Arcade.prototype = {
|
||||
rebounded = true;
|
||||
}
|
||||
|
||||
return rebounded;
|
||||
|
||||
if (body.sprite.debug)
|
||||
{
|
||||
console.log('checkBounds finished', body.blocked);
|
||||
console.log('checkBounds finished', rebounded, body.blocked);
|
||||
}
|
||||
|
||||
return rebounded;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+41
-26
@@ -395,15 +395,15 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||
|
||||
if (this.sprite.debug)
|
||||
{
|
||||
// console.log('Body preUpdate x:', this.x, 'y:', this.y);
|
||||
console.log('Body preUpdate x:', this.x, 'y:', this.y);
|
||||
// console.log('Body preUpdate Sprite x:', this.sprite.x, 'y:', this.sprite.y);
|
||||
// console.log('Body preUpdate Sprite world:', this.sprite.world.x, 'y:', this.sprite.world.y);
|
||||
// console.log('Body preUpdate Sprite position:', this.sprite.position.x, 'y:', this.sprite.position.y);
|
||||
// console.log('Body preUpdate Sprite localTransform:', this.sprite.localTransform[2], 'y:', this.sprite.localTransform[5]);
|
||||
// console.log('Body preUpdate Sprite worldTransform:', this.sprite.worldTransform[2], 'y:', this.sprite.worldTransform[5]);
|
||||
// console.log('Body preUpdate x:', this.x, 'y:', this.y, 'left:', this.left, 'right:', this.right, 'WAS', this.preX, this.preY);
|
||||
// console.log('Body preUpdate blocked:', this.blocked, this.blockFlags);
|
||||
// console.log('Body preUpdate velocity:', this.velocity.x, this.velocity.y);
|
||||
console.log('Body preUpdate blocked:', this.blocked, this.blockFlags);
|
||||
console.log('Body preUpdate velocity:', this.velocity.x, this.velocity.y);
|
||||
// console.log('Body preUpdate rotation:', this.rotation, this.preRotation);
|
||||
}
|
||||
|
||||
@@ -555,14 +555,18 @@ if (this.sprite.debug)
|
||||
|
||||
if (x)
|
||||
{
|
||||
if (rebound && this.bounce.x !== 0 && (this.blocked.left || this.blocked.right))
|
||||
if (rebound && this.bounce.x !== 0 && (this.blocked.left || this.blocked.right || this.touching.left || this.touching.right))
|
||||
{
|
||||
this.velocity.x *= -this.bounce.x;
|
||||
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
|
||||
|
||||
if (this.sprite.debug)
|
||||
// Don't rebound if they've already rebounded in this frame
|
||||
if (!(this._vx <= 0 && this.velocity.x > 0) && !(this._vx >= 0 && this.velocity.x < 0))
|
||||
{
|
||||
console.log('X rebound applied');
|
||||
this.velocity.x *= -this.bounce.x;
|
||||
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
|
||||
|
||||
if (this.sprite.debug)
|
||||
{
|
||||
console.log('X rebound applied', this._vx, 'to', this.velocity.x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,7 +574,7 @@ if (this.sprite.debug)
|
||||
{
|
||||
var gx = this.getUpwardForce();
|
||||
|
||||
if ((this.blocked.left && (gx < 0 || this.velocity.x < 0)) || (this.blocked.right && (gx > 0 || this.velocity.x > 0)))
|
||||
if (((this.blocked.left || this.touching.left) && (gx < 0 || this.velocity.x < 0)) || ((this.blocked.right || this.touching.right) && (gx > 0 || this.velocity.x > 0)))
|
||||
{
|
||||
this.velocity.x = 0;
|
||||
|
||||
@@ -579,24 +583,30 @@ if (this.sprite.debug)
|
||||
console.log('reboundCheck X zeroed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.sprite.debug)
|
||||
{
|
||||
console.log('reboundCheck X', this.velocity.x, 'gravity', gx);
|
||||
if (this.sprite.debug)
|
||||
{
|
||||
console.log('reboundCheck X', this.velocity.x, 'gravity', gx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (y)
|
||||
{
|
||||
if (rebound && this.bounce.y !== 0 && (this.blocked.up || this.blocked.down))
|
||||
if (rebound && this.bounce.y !== 0 && (this.blocked.up || this.blocked.down || this.touching.up || this.touching.down))
|
||||
{
|
||||
this.velocity.y *= -this.bounce.y;
|
||||
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
|
||||
|
||||
if (this.sprite.debug)
|
||||
// Don't rebound if they've already rebounded in this frame
|
||||
if (!(this._vy <= 0 && this.velocity.y > 0) && !(this._vy >= 0 && this.velocity.y < 0))
|
||||
{
|
||||
console.log('Y rebound applied');
|
||||
this.velocity.y *= -this.bounce.y;
|
||||
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
|
||||
|
||||
if (this.sprite.debug)
|
||||
{
|
||||
console.log('Y rebound applied', this._vy, 'to', this.velocity.y);
|
||||
console.log('Y rebound check 1', !(this._vy <= 0 && this.velocity.y > 0));
|
||||
console.log('Y rebound check 2', !(this._vy >= 0 && this.velocity.y < 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,7 +614,7 @@ if (this.sprite.debug)
|
||||
{
|
||||
var gy = this.getDownwardForce();
|
||||
|
||||
if ((this.blocked.up && (gy < 0 || this.velocity.y < 0)) || (this.blocked.down && (gy > 0 || this.velocity.y > 0)))
|
||||
if (((this.blocked.up || this.touching.up) && (gy < 0 || this.velocity.y < 0)) || ((this.blocked.down || this.touching.down) && (gy > 0 || this.velocity.y > 0)))
|
||||
{
|
||||
this.velocity.y = 0;
|
||||
|
||||
@@ -613,11 +623,11 @@ if (this.sprite.debug)
|
||||
console.log('reboundCheck Y zeroed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.sprite.debug)
|
||||
{
|
||||
console.log('reboundCheck Y', this.velocity.y, 'gravity', gy);
|
||||
if (this.sprite.debug)
|
||||
{
|
||||
console.log('reboundCheck Y', this.velocity.y, 'gravity', gy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -989,12 +999,17 @@ if (this.sprite.debug)
|
||||
|
||||
if (hasSeparated)
|
||||
{
|
||||
console.log('Body hasSeparated');
|
||||
this.game.physics.checkBounds(this);
|
||||
this.game.physics.checkBounds(body);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.addContact(body);
|
||||
// They can only contact like this if at least one of their sides is open, otherwise it's a separation
|
||||
if (!this.checkCollision.up || !this.checkCollision.down || !this.checkCollision.left || !this.checkCollision.right || !body.checkCollision.up || !body.checkCollision.down || !body.checkCollision.left || !body.checkCollision.right)
|
||||
{
|
||||
this.addContact(body);
|
||||
}
|
||||
}
|
||||
|
||||
return hasSeparated;
|
||||
|
||||
+1
-1
@@ -433,7 +433,7 @@ Phaser.Utils.Debug.prototype = {
|
||||
this.start(x, y, color, 210);
|
||||
|
||||
this.splitline('x: ' + sprite.body.x.toFixed(2), 'y: ' + sprite.body.y.toFixed(2), 'width: ' + sprite.width, 'height: ' + sprite.height);
|
||||
this.splitline('speed: ' + sprite.body.speed.toFixed(2), 'angle: ' + sprite.body.angle.toFixed(2), 'friction: ' + sprite.body.friction);
|
||||
this.splitline('speed: ' + sprite.body.speed.toFixed(2), 'angle: ' + sprite.body.angle.toFixed(2), 'linear damping: ' + sprite.body.linearDamping);
|
||||
this.splitline('blocked left: ' + sprite.body.blocked.left, 'right: ' + sprite.body.blocked.right, 'up: ' + sprite.body.blocked.up, 'down: ' + sprite.body.blocked.down);
|
||||
this.splitline('touching left: ' + sprite.body.touching.left, 'right: ' + sprite.body.touching.right, 'up: ' + sprite.body.touching.up, 'down: ' + sprite.body.touching.down);
|
||||
this.splitline('gravity x: ' + sprite.body.gravity.x, 'y: ' + sprite.body.gravity.y, 'world gravity x: ' + this.game.physics.gravity.x, 'y: ' + this.game.physics.gravity.y);
|
||||
|
||||
Reference in New Issue
Block a user