Updated world so the update run uses the linked list. Sprite.getLocalPosition now almost working, but falls over for children.

This commit is contained in:
Richard Davey
2013-09-01 03:57:24 +01:00
parent 188d6239a3
commit 801c2af9d4
4 changed files with 50 additions and 33 deletions
+4 -24
View File
@@ -140,32 +140,13 @@ Phaser.Sprite.prototype.update = function() {
this.position.x = this._x - (this.game.world.camera.x * this.scrollFactor.x);
this.position.y = this._y - (this.game.world.camera.y * this.scrollFactor.y);
// Update the edge points (sx, sy)
this.offset.setTo(this.x - (this.anchor.x * this.width), this.y - (this.anchor.y * this.height));
// Update the edge points
this.offset.setTo(this._x - (this.anchor.x * this.width), this._y - (this.anchor.y * this.height));
// var sx = s.x - offsetX;
// var sy = s.y - offsetY;
// top left
this.getLocalPosition(this.topLeft, this.offset.x, this.offset.y);
// var p1 = getLocalPosition(sx, sy, s);
// top right
this.getLocalPosition(this.topRight, this.offset.x + this.width, this.offset.y);
// var p2 = getLocalPosition(sx + s.width, sy, s);
// bottom left
this.getLocalPosition(this.bottomLeft, this.offset.x, this.offset.y + this.height);
// var p3 = getLocalPosition(sx, sy + s.height, s);
// bottom right
this.getLocalPosition(this.bottomRight, this.offset.x + this.width, this.offset.y + this.height);
// var p4 = getLocalPosition(sx + s.width, sy + s.height, s);
// p1.add(s.x, s.y);
// p2.add(s.x, s.y);
// p3.add(s.x, s.y);
// p4.add(s.x, s.y);
// this.checkBounds();
@@ -185,9 +166,8 @@ Phaser.Sprite.prototype.getLocalPosition = function(p, x, y) {
this._id = 1 / (this._a00 * this._a11 + this._a01 * -this._a10);
p.x = (this._a11 * this._id * x + -this._a01 * this._id * y + (this._a12 * this._a01 - this._a02 * this._a11) * this._id) * this.scale.x;
p.y = (this._a00 * this._id * y + -this._a10 * this._id * x + (-this._a12 * this._a00 + this._a02 * this._a10) * this._id) * this.scale.y;
p.add(this.x, this.y);
p.x = ((this._a11 * this._id * x + -this._a01 * this._id * y + (this._a12 * this._a01 - this._a02 * this._a11) * this._id) * this.scale.x) + this.x;
p.y = ((this._a00 * this._id * y + -this._a10 * this._id * x + (-this._a12 * this._a00 + this._a02 * this._a10) * this._id) * this.scale.y) + this.y;
return p;