Merged N+ physics in and tidied up the Docs folder and logos.

This commit is contained in:
Richard Davey
2013-08-11 12:15:53 +01:00
parent aff7d99a8a
commit c2d7fb7fab
108 changed files with 17900 additions and 2017 deletions
+39 -28
View File
@@ -57,6 +57,8 @@ module Phaser.Components {
private _angle: number;
private _distance: number;
private _prevRotation: number;
private _flippedX: boolean;
private _flippedY: boolean;
/**
* Reference to Phaser.Game
@@ -197,7 +199,7 @@ module Phaser.Components {
this.parent.x = x + (this.parent.x - this.center.x);
this.parent.y = y + (this.parent.y - this.center.y);
this.setCache();
//this.setCache();
}
@@ -218,10 +220,8 @@ module Phaser.Components {
this._size.y = this.parent.height;
this._origin.x = this.origin.x;
this._origin.y = this.origin.y;
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._prevRotation = this.rotation;
if (this.parent.texture && this.parent.texture.renderRotation)
@@ -246,6 +246,9 @@ module Phaser.Components {
this._pos.x = this.parent.x;
this._pos.y = this.parent.y;
this._flippedX = this.parent.texture.flippedX;
this._flippedY = this.parent.texture.flippedY;
}
/**
@@ -274,10 +277,8 @@ module Phaser.Components {
}
// 2) Rotation change
if (this.rotation != this._prevRotation)
if (this.rotation != this._prevRotation || this._dirty)
{
this._sc.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._sc.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
this._scA.y = Math.cos((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
this._scA.x = Math.sin((this.rotation + this.rotationOffset) * Phaser.GameMath.DEG_TO_RAD + this._angle);
@@ -297,7 +298,7 @@ module Phaser.Components {
this._dirty = true;
}
// If it has moved, update the edges and center
// 3) If it has moved (or any of the above) then update the edges and center
if (this._dirty || this.parent.x != this._pos.x || this.parent.y != this._pos.y)
{
this.center.x = this.parent.x + this._distance * this._scA.y;
@@ -310,34 +311,44 @@ module Phaser.Components {
this._pos.x = this.parent.x;
this._pos.y = this.parent.y;
// Translate
this.local.data[2] = this.parent.x;
this.local.data[5] = this.parent.y;
}
// Scale and Skew
if (this.parent.texture.flippedX)
if (this._dirty || this._flippedX != this.parent.texture.flippedX)
{
this.local.data[0] = this._sc.y * -this.scale.x;
this.local.data[3] = (this._sc.x * -this.scale.x) + this.skew.x;
}
else
{
this.local.data[0] = this._sc.y * this.scale.x;
this.local.data[3] = (this._sc.x * this.scale.x) + this.skew.x;
this._flippedX = this.parent.texture.flippedX;
if (this._flippedX)
{
this.local.data[0] = this._sc.y * -this.scale.x;
this.local.data[3] = (this._sc.x * -this.scale.x) + this.skew.x;
}
else
{
this.local.data[0] = this._sc.y * this.scale.x;
this.local.data[3] = (this._sc.x * this.scale.x) + this.skew.x;
}
}
if (this.parent.texture.flippedY)
if (this._dirty || this._flippedY != this.parent.texture.flippedY)
{
this.local.data[4] = this._sc.y * -this.scale.y;
this.local.data[1] = -(this._sc.x * -this.scale.y) + this.skew.y;
}
else
{
this.local.data[4] = this._sc.y * this.scale.y;
this.local.data[1] = -(this._sc.x * this.scale.y) + this.skew.y;
}
this._flippedY = this.parent.texture.flippedY;
// Translate
this.local.data[2] = this.parent.x;
this.local.data[5] = this.parent.y;
if (this._flippedY)
{
this.local.data[4] = this._sc.y * -this.scale.y;
this.local.data[1] = -(this._sc.x * -this.scale.y) + this.skew.y;
}
else
{
this.local.data[4] = this._sc.y * this.scale.y;
this.local.data[1] = -(this._sc.x * this.scale.y) + this.skew.y;
}
}
}