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
+21 -2
View File
@@ -51,10 +51,29 @@ Phaser.World.prototype = {
this.camera.update();
for (var child in this._container.children)
var displayObject = this._stage;
// once the display object hits this. we can break the loop
var testObject = displayObject.last._iNext;
displayObject = displayObject.first;
do
{
this._container.children[child].update();
if (!displayObject.visible)
{
displayObject = displayObject.last._iNext;
continue;
}
if (displayObject['update'])
{
displayObject.update();
}
// count++
displayObject = displayObject._iNext;
}
while(displayObject != testObject)
},
+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;
+3 -3
View File
@@ -272,7 +272,7 @@ Phaser.Utils.Debug.prototype = {
this.start(x, y, color);
this.line('Sprite: ' + ' (' + sprite.width + ' x ' + sprite.height + ') anchor: ' + sprite.anchor.x + ' x ' + sprite.anchor.y);
// this.line('x: ' + sprite.x.toFixed(1) + ' y: ' + sprite.y.toFixed(1) + ' rotation: ' + sprite.rotation.toFixed(1));
this.line('x: ' + sprite.x.toFixed(1) + ' y: ' + sprite.y.toFixed(1) + ' rotation: ' + sprite.rotation.toFixed(1));
// this.line('wx: ' + sprite.worldView.x + ' wy: ' + sprite.worldView.y + ' ww: ' + sprite.worldView.width.toFixed(1) + ' wh: ' + sprite.worldView.height.toFixed(1) + ' wb: ' + sprite.worldView.bottom + ' wr: ' + sprite.worldView.right);
// this.line('sx: ' + sprite.scale.x.toFixed(1) + ' sy: ' + sprite.scale.y.toFixed(1));
@@ -288,8 +288,8 @@ Phaser.Utils.Debug.prototype = {
this.line('scale y: ' + sprite.worldTransform[4]);
this.line('tx: ' + sprite.worldTransform[2]);
this.line('ty: ' + sprite.worldTransform[5]);
this.line('skew x: ' + sprite.worldTransform[1]);
this.line('skew y: ' + sprite.worldTransform[3]);
this.line('skew x: ' + sprite.worldTransform[3]);
this.line('skew y: ' + sprite.worldTransform[1]);
// this.line('tx: ' + sprite.texture.width.toFixed(1) + ' ty: ' + sprite.texture.height.toFixed(1));
// this.line('center x: ' + sprite.transform.center.x + ' y: ' + sprite.transform.center.y);