mirror of
https://github.com/wassname/phaser.git
synced 2026-08-09 12:20:34 +08:00
Merged N+ physics in and tidied up the Docs folder and logos.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user